## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
from CvPythonExtensions import *
import CvUtil
import ScreenInput
import CvScreenEnums
import CvConfigParser
import CvPath
import os
import os.path
import Popup as PyPopup
import shutil 
import TechInfoWriter

PIXEL_INCREMENT = 7
BOX_INCREMENT_WIDTH = 36 # Used to be 33 #Should be a multiple of 3...
BOX_INCREMENT_HEIGHT = 9 #Should be a multiple of 3...
BOX_INCREMENT_Y_SPACING = 6 #Should be a multiple of 3...
BOX_INCREMENT_X_SPACING = 9 #Should be a multiple of 3...

TEXTURE_SIZE = 22
X_START = 6
X_INCREMENT = 27
Y_ROW = 32

# globals
gc = CyGlobalContext()
ArtFileMgr = CyArtFileMgr()
localText = CyTranslator()

zLevel = -6.1

# Change this to change the location where the resulting CIV4TechInfos.xml file 
# will be saved. So if the default value is left to "Test" then the 
# CIV4TechInfos.xml file would be written in a directory called "Test" inside 
# of the Tech Tree Editor mod folder.
# Default value is Test
g_strSaveDirectoryLocation = "Test"

# Change the value to false if the assets directory structure shouldn't be 
# created at the directory specified by the "Save Directory Location".
# Default value is True
g_bCreateAssetHierarchy = True

# Change the value to false if the changes made shouldn't be saved into the 
# assets directory for the tech editor. Changing it to false will require 
# manual copying of the saved files from the directory specified in the 
# "Save Directory Location" configurable option to the editor's asset directory 
# when wanting to edit existing mod files.
# Default value is True
g_bSaveChangesInEditorAssetsDirectory = True

def loadConfigurationValues():
	global g_strSaveDirectoryLocation
	global g_bCreateAssetHierarchy
	global g_bSaveChangesInEditorAssetsDirectory
	
	config = CvConfigParser.CvConfigParser("Tech Tree Editor Config.ini")

	if(config != None):
		g_strSaveDirectoryLocation = config.get("Tech Tree Editor", "Save Directory Location", "Test")
		g_bCreateAssetHierarchy = config.getboolean("Tech Tree Editor", "Create Asset Hierarchy", True)
		g_bSaveChangesInEditorAssetsDirectory = config.getboolean("Tech Tree Editor", "Save Changes In Editor Assets Directory", True)

		if(len(g_strSaveDirectoryLocation) == 0):
			g_strSaveDirectoryLocation = "Test"
			
class CvTechTreeEditor:
	"Tech Tree Editor Screen"
	
	def __init__(self):
		self.iSelectedTech = -1
		self.iOldSelectedTech = -1
		self.nWidgetCount = 0
		self.bMinimized = false
		loadConfigurationValues()
		
	def hideScreen (self):
	
		# Get the screen
		screen = CyGInterfaceScreen( "CvTechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )

		# Hide the screen
		screen.hideScreen()
	
	# Screen construction function
	def interfaceScreen(self):
			
		if ( CyGame().isPitbossHost() ):
			return

		# Create a new screen, called TechTreeEditor, using the file CvTechTreeEditor.py for input
		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )
		screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)
			
		if ( screen.isPersistent() ):
			self.updateTechRecords(false)
			return		
		
		#screen.setPersistent( True )
		
		# Here we set the background widget and exit button, and we show the screen
		screen.showWindowBackground( False )
		screen.setDimensions(screen.centerX(0), screen.centerY(0), 1024, 768)
		screen.addPanel( "TechTopPanel", u"", u"", True, False, 0, 0, 1024, 55, PanelStyles.PANEL_STYLE_TOPBAR )
		screen.addDDSGFC("TechBG", ArtFileMgr.getInterfaceArtInfo("SCREEN_BG_OPAQUE").getPath(), 0, 48, 1024, 672, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		screen.addPanel( "TechBottomPanel", u"", u"", True, False, 0, 713, 1024, 55, PanelStyles.PANEL_STYLE_BOTTOMBAR )
		screen.setText( "TechTreeEditorExit", "Background", u"<font=4>" + CyTranslator().getText("TXT_KEY_PEDIA_SCREEN_EXIT", ()).upper() + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, 994, 726, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1 )
		screen.setActivation( "TechTreeEditorExit", ActivationTypes.ACTIVATE_MIMICPARENTFOCUS )

		screen.setText( "TechTreeEditorSave", "Background", u"<font=4>" + CyTranslator().getText("TXT_KEY_EDITOR_SCREEN_SAVE", ()).upper() + "</font>", CvUtil.FONT_LEFT_JUSTIFY, 30, 726, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		screen.setActivation( "TechTreeEditorSave", ActivationTypes.ACTIVATE_MIMICPARENTFOCUS )

		screen.setText( "AddTech", "Background", u"<font=4>" + CyTranslator().getText("TXT_KEY_ADD_TECH", ()).upper().replace(":","") + "</font>", CvUtil.FONT_LEFT_JUSTIFY, 125, 726, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		screen.setActivation( "TechTreeEditorSave", ActivationTypes.ACTIVATE_MIMICPARENTFOCUS )
		
		# Header...
		szText = u"<font=4>"
		szText = szText +  CyTranslator().getText("TXT_KEY_EDITOR_TECH_EDITOR_TITLE", ()).upper()
		szText = szText + u"</font>"
		screen.setLabel( "TechTitleHeader", "Background", szText, CvUtil.FONT_CENTER_JUSTIFY, 502, 8, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

		# Make the scrollable area for the city list...
		screen.addScrollPanel( "TechList", u"", 0, 64, 1024, 626, PanelStyles.PANEL_STYLE_EXTERNAL )
		screen.setActivation( "TechList", ActivationTypes.ACTIVATE_NORMAL )
		screen.hide( "TechList" )
		
		# Add the Highlight
		#screen.addDDSGFC( "TechHighlight", ArtFileMgr.getInterfaceArtInfo("TECH_HIGHLIGHT").getPath(), 0, 0, self.getXStart() + 6, 12 + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT ), WidgetTypes.WIDGET_GENERAL, -1, -1 )
		#screen.hide( "TechHighlight" )

		# Place the tech blocks
		self.placeTechs()
	
		# Draw the arrows
		iUpdatedTech = -1
		self.drawArrows(iUpdatedTech)
		
		self.placeTechInfoPanel(screen)
	

	def placeTechInfoPanel(self, screen):
		screen.addPanel( "TechInfoPanel", u"", u"", True, True, (1024/2) - 118, 55, (1024/2) + 100, (713-75), PanelStyles.PANEL_STYLE_BLUELARGE )
		screen.hide("TechInfoPanel")
	
		screen.addPanel( "TechNamePanel", u"", u"", True, True, (1024/2)-112, 55+6, (1024/2)+88, 90, PanelStyles.PANEL_STYLE_BLUELARGE )
		screen.hide("TechNamePanel") #-12 -> -112

		if(self.iSelectedTech < 0):
			screen.setImageButton("techButton", gc.getTechInfo(0).getButton(), (1024/2), 55+(55/4)+6, 64, 64, WidgetTypes.WIDGET_CHANGE_TECH_IMAGE, 0, -1)
			screen.setImageButton("DeleteTechButton", ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_CANCEL").getPath(), (1024/2)+100, 55+(55/4)+6, 32, 32, WidgetTypes.WIDGET_DELETE_TECH, 0, -1)
		else:
			screen.setImageButton("techButton", gc.getTechInfo(self.iSelectedTech).getButton(),  (1024/2), 55+(55/4)+6, 64, 64, WidgetTypes.WIDGET_CHANGE_TECH_IMAGE, self.iSelectedTech, -1)
			screen.setImageButton("DeleteTechButton", ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_CANCEL").getPath(), (1024/2)+100, 55+(55/4)+6, 32, 32, WidgetTypes.WIDGET_DELETE_TECH, self.iSelectedTech, -1)
		screen.hide("techButton")
		screen.hide("DeleteTechButton")


		screen.addPanel( "TechInfoDetailsPanel", u"", u"", True, True, (1024/2)-112, 110+35, (1024/2)+88, (713-110-55-20-35), PanelStyles.PANEL_STYLE_BLUELARGE )
		screen.hide("TechInfoDetailsPanel")#-12 -> -112, -12->88

		screen.addPanel( "InnerTechInfoDetailsPanel", u"", u"", True, True, (1024/2)-100, 122+35, (1024/2)+50, (713-110-55-20-24-35), PanelStyles.PANEL_STYLE_EMPTY )
		screen.attachPanel("InnerTechInfoDetailsPanel", "dummy1", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.hide("InnerTechInfoDetailsPanel")# 0 -> -100, -30->50

		screen.setText( "TechInfoClose", "Background", u"<font=4>Close</font>", CvUtil.FONT_RIGHT_JUSTIFY, 1024+70, 713-55-10-6, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL , -1, -1 )
		screen.hide("TechInfoClose")# -30 -> +70
				
		screen.attachPanel("InnerTechInfoDetailsPanel", "LocationPanel", "", "", False, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("LocationPanel", "InnerLocationPanel", "", "", True, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("LocationPanel", "SubLocationPanel", "", "", True, false, PanelStyles.PANEL_STYLE_BLUELARGE)
		screen.attachPanel("SubLocationPanel", "SubInnerLocationPanel1", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("SubLocationPanel", "SubInnerLocationPanel2", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("SubLocationPanel", "SubInnerLocationPanel3", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachPanel("InnerLocationPanel", "InnerLocationPanel1", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachLabel( "InnerLocationPanel1", "LocationLabel", "    <font=3>Tech Location:     </font>")
		screen.attachPanel("InnerLocationPanel", "InnerLocationPanel2", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("InnerLocationPanel", "InnerLocationPanel3", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("InnerLocationPanel", "InnerLocationPanel4", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		for i in range(8):
			screen.attachPanel("LocationPanel", "LocationPanelDummy%s" %(i), "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachPanel("SubInnerLocationPanel1", "UpperRightLocationPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("SubInnerLocationPanel1", "UpperCenterLocationPanel", "", "", false, false, PanelStyles.PANEL_STYLE_BLUELARGE)
		screen.attachPanel("SubInnerLocationPanel1", "UpperLeftLocationPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		szLocation = "(0 , 0)"
		szUpArrow = "     &#47;&#92;"
		szDownArrow = "      &#92;&#47;"
		
		screen.attachLabel( "UpperRightLocationPanel", "UpperRightLocationValue", "      ")
		screen.attachTextGFC("UpperCenterLocationPanel", "UpperCenterLocationValue", szUpArrow.center(len(szLocation)-4), FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
		screen.attachLabel( "UpperLeftLocationPanel", "UpperLeftLocationValue", "      ")

		screen.attachPanel("SubInnerLocationPanel2", "MiddleLeftLocationPanel", "", "", false, false, PanelStyles.PANEL_STYLE_BLUELARGE)
		screen.attachPanel("SubInnerLocationPanel2", "MiddleCenterLocationPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("SubInnerLocationPanel2", "MiddleRightLocationPanel", "", "", false, false, PanelStyles.PANEL_STYLE_BLUELARGE)

		screen.attachTextGFC("MiddleLeftLocationPanel", "MiddleLeftLocationValue", "<font=4>&lt;</font>", FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
		screen.attachLabel( "MiddleCenterLocationPanel", "MiddleCenterLocationValue", szLocation)
		screen.attachTextGFC("MiddleRightLocationPanel", "MiddleRightLocationValue", "<font=4>&gt;</font>", FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

		screen.attachPanel("SubInnerLocationPanel3", "BottomRightLocationPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("SubInnerLocationPanel3", "BottomCenterLocationPanel", "", "", false, false, PanelStyles.PANEL_STYLE_BLUELARGE)
		screen.attachPanel("SubInnerLocationPanel3", "BottomLeftLocationPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachLabel( "BottomRightLocationPanel", "BottomRightLocationValue", "    ")
		screen.attachTextGFC("BottomCenterLocationPanel", "BottomCenterLocationValue", szDownArrow.center(len(szLocation)-4), FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
		screen.attachLabel( "BottomLeftLocationPanel", "BottomLeftLocationValue", "    ")
				
		screen.attachPanel("InnerTechInfoDetailsPanel", "DummyInnerTechInfoDetailsPanel%s" %(self.getNextWidgetName()), " ", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachPanel("InnerTechInfoDetailsPanel", "TechEditTablePanel", "", "", true, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachPanel("InnerTechInfoDetailsPanel", "DummyInnerTechInfoDetailsPanel%s" %(self.getNextWidgetName()), " ", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachTableControlGFC("TechEditTablePanel", "TechEditTable", 3, False, False, 64,64,TableStyles.TABLE_STYLE_CITY)
		
		screen.attachPanel("InnerTechInfoDetailsPanel", "DummyInnerTechInfoDetailsPanel%s" %(self.getNextWidgetName()), " ", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachLabel( "InnerTechInfoDetailsPanel", "DomainExtraMovesLabel", "    <font=3>Domain Extra Moves:     </font>")
		
		screen.attachPanel("InnerTechInfoDetailsPanel", "DomainExtraMovesTablePanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachPanel("DomainExtraMovesTablePanel", "InnerDomainExtraMovesTablePanel", "", "", true, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachTableControlGFC("InnerDomainExtraMovesTablePanel", "DomainExtraMovesTable", 4, False, False, 64,64,TableStyles.TABLE_STYLE_EMPTY)
		screen.attachPanel("DomainExtraMovesTablePanel", "DomainExtraMovesTablePanelDummy1", "", "", true, false, PanelStyles.PANEL_STYLE_EMPTY)
		
		for iI in range(DomainTypes.NUM_DOMAIN_TYPES):

			screen.appendTableRow("DomainExtraMovesTable")
			sliderLabel = str("%sExtraMovesSlider" %(gc.getDomainInfo(iI).getDescription().replace(" ","")))
			movesLabel = str("%sExtraMovesLabel" %(gc.getDomainInfo(iI).getDescription().replace(" ","")))
			valueLabel = str("%sExtraMovesValue" %(gc.getDomainInfo(iI).getDescription().replace(" ","")))
			
			screen.attachSlider("InnerTechInfoDetailsPanel", sliderLabel, 0, 0, 150, 20, 0, -49, 49, WidgetTypes.WIDGET_GENERAL, iI, -1, false)
			screen.attachLabel( "InnerTechInfoDetailsPanel", movesLabel,"            <font=3>%s:     </font>" %(gc.getDomainInfo(iI).getDescription()))
			screen.attachLabel( "InnerTechInfoDetailsPanel", valueLabel, "<font=3>0</font>" )

			screen.attachControlToTableCell(movesLabel,"DomainExtraMovesTable", screen.getTableNumRows("DomainExtraMovesTable")-1,1)
			screen.attachControlToTableCell(sliderLabel,"DomainExtraMovesTable", screen.getTableNumRows("DomainExtraMovesTable")-1,2)
			screen.attachControlToTableCell(valueLabel,"DomainExtraMovesTable", screen.getTableNumRows("DomainExtraMovesTable")-1,3)
		
		screen.appendTableRow("DomainExtraMovesTable")
		screen.attachLabel( "InnerTechInfoDetailsPanel", "DomainExtraMovesTableDummyLabel", "                                         " )
		screen.attachControlToTableCell("DomainExtraMovesTableDummyLabel","DomainExtraMovesTable", screen.getTableNumRows("DomainExtraMovesTable")-1,2)


		screen.attachLabel( "InnerTechInfoDetailsPanel", "FlavorValuesLabel", "    <font=3>Flavors:     </font>")
		
		screen.attachPanel("InnerTechInfoDetailsPanel", "FlavorValuesTablePanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachPanel("FlavorValuesTablePanel", "InnerFlavorValuesTablePanel", "", "", true, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachTableControlGFC("InnerFlavorValuesTablePanel", "FlavorValuesTable", 4, False, False, 64,64,TableStyles.TABLE_STYLE_EMPTY)
		screen.attachPanel("FlavorValuesTablePanel", "FlavorValuesTablePanelDummy1", "", "", true, false, PanelStyles.PANEL_STYLE_EMPTY)
		
		for iI in range(gc.getNumFlavorTypes()):

			screen.appendTableRow("FlavorValuesTable")

			sliderLabel = str("%sValuesSlider" %(gc.getFlavorTypes(iI).replace(" ","")))
			flavorLabel = str("%sValuesLabel" %(gc.getFlavorTypes(iI).replace(" ","")))
			valueLabel = str("%sValuesValue" %(gc.getFlavorTypes(iI).replace(" ","")))
			
			screen.attachSlider("InnerTechInfoDetailsPanel", sliderLabel, 0, 0, 150, 20, 0, -49, 49, WidgetTypes.WIDGET_GENERAL, iI, -1, false)
			screen.attachLabel( "InnerTechInfoDetailsPanel", flavorLabel,"            <font=3>%s:     </font>" %(gc.getFlavorTypes(iI)))
			screen.attachLabel( "InnerTechInfoDetailsPanel", valueLabel, "<font=3>0</font>" )

			screen.attachControlToTableCell(flavorLabel,"FlavorValuesTable", screen.getTableNumRows("FlavorValuesTable")-1,1)
			screen.attachControlToTableCell(sliderLabel,"FlavorValuesTable", screen.getTableNumRows("FlavorValuesTable")-1,2)
			screen.attachControlToTableCell(valueLabel,"FlavorValuesTable", screen.getTableNumRows("FlavorValuesTable")-1,3)
		
		screen.appendTableRow("FlavorValuesTable")
		screen.attachLabel( "InnerTechInfoDetailsPanel", "FlavorValuesTableDummyLabel", "                                         " )
		screen.attachControlToTableCell("FlavorValuesTableDummyLabel","FlavorValuesTable", screen.getTableNumRows("FlavorValuesTable")-1,2)

		screen.attachPanel("InnerTechInfoDetailsPanel", "DummyInnerTechInfoDetailsPanel%s" %(self.getNextWidgetName()), " ", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachLabel( "InnerTechInfoDetailsPanel", "PrereqOrTechsLabel", "    <font=3>Or Prereq Techs (Max %s):     </font>" %(gc.getDefineINT("NUM_OR_TECH_PREREQS")))
		screen.attachPanel("InnerTechInfoDetailsPanel", "MainPrereqOrTechsPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachPanel("InnerTechInfoDetailsPanel", "AddPrereqOrTechPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachLabel( "AddPrereqOrTechPanel", "AddPrereqOrTechLabel", "    <font=3>Add Or Prereq Tech: </font>")
		
		screen.attachPanel("InnerTechInfoDetailsPanel", "DummyInnerTechInfoDetailsPanel%s" %(self.getNextWidgetName()), " ", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachLabel( "InnerTechInfoDetailsPanel", "PrereqAndTechsLabel", "    <font=3>And Prereq Techs (Max %s):     </font>" %(gc.getDefineINT("NUM_AND_TECH_PREREQS")))
		screen.attachPanel("InnerTechInfoDetailsPanel", "MainPrereqAndTechsPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachPanel("InnerTechInfoDetailsPanel", "AddPrereqAndTechPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachLabel( "AddPrereqAndTechPanel", "AddPrereqAndTechLabel", "    <font=3>Add And Prereq Tech: </font>")


		screen.attachPanel("InnerTechInfoDetailsPanel", "DummyInnerTechInfoDetailsPanel%s" %(self.getNextWidgetName()), " ", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachLabel( "InnerTechInfoDetailsPanel", "CommerceFlexibleLabel", "    <font=3>Enables Rate Adjustment For:     </font>")

		screen.attachPanel("InnerTechInfoDetailsPanel", "CommerceFlexibleTablePanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachPanel("CommerceFlexibleTablePanel", "InnerCommerceFlexibleTablePanel", "", "", true, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachTableControlGFC("InnerCommerceFlexibleTablePanel", "CommerceFlexibleTable", 3, False, False, 64,64,TableStyles.TABLE_STYLE_EMPTY)
		screen.attachPanel("CommerceFlexibleTablePanel", "CommerceFlexibleTablePanelDummy1", "", "", true, false, PanelStyles.PANEL_STYLE_EMPTY)
		
		for iI in range(CommerceTypes.NUM_COMMERCE_TYPES):

			screen.appendTableRow("CommerceFlexibleTable")

			commerceLabel = str("%sExtraMovesLabel" %(gc.getCommerceInfo(iI).getDescription().replace(" ","")))
			checkboxLabel = "CommerceFlexible%s" %(iI)
			
			screen.attachLabel( "InnerTechInfoDetailsPanel", commerceLabel,"            <font=3>%s:     </font>" %(gc.getCommerceInfo(iI).getDescription()))
			screen.attachCheckBoxGFC("InnerTechInfoDetailsPanel", checkboxLabel, "Art/Interface/Buttons/unchecked.dds", "", 20, 20, WidgetTypes.WIDGET_GENERAL, iI, -1, ButtonStyles.BUTTON_STYLE_LABEL)

			screen.attachControlToTableCell(commerceLabel,"CommerceFlexibleTable", screen.getTableNumRows("CommerceFlexibleTable")-1,1)
			screen.attachControlToTableCell(checkboxLabel,"CommerceFlexibleTable", screen.getTableNumRows("CommerceFlexibleTable")-1,2)
				
		
		screen.attachPanel("InnerTechInfoDetailsPanel", "DummyInnerTechInfoDetailsPanel%s" %(self.getNextWidgetName()), " ", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachLabel( "InnerTechInfoDetailsPanel", "TerrainTradeLabel", "    <font=3>Enables Trade On:     </font>")


		screen.attachPanel("InnerTechInfoDetailsPanel", "TerrainTradeTablePanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		screen.attachPanel("TerrainTradeTablePanel", "InnerTerrainTradeTablePanel", "", "", true, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachTableControlGFC("InnerTerrainTradeTablePanel", "TerrainTradeTable", 3, False, False, 64,64,TableStyles.TABLE_STYLE_EMPTY)
		screen.attachPanel("TerrainTradeTablePanel", "TerrainTradeTablePanelDummy1", "", "", true, false, PanelStyles.PANEL_STYLE_EMPTY)
		
		for iI in range(gc.getNumTerrainInfos()):

			screen.appendTableRow("TerrainTradeTable")

			tradeLabel = str("%sExtraMovesLabel" %(gc.getTerrainInfo(iI).getDescription().replace(" ","")))
			checkboxLabel = "TerrainTrade%s" %(iI)
			
			screen.attachLabel( "InnerTechInfoDetailsPanel", tradeLabel,"            <font=3>%s:     </font>" %(gc.getTerrainInfo(iI).getDescription()))
			screen.attachCheckBoxGFC("InnerTechInfoDetailsPanel", checkboxLabel, "Art/Interface/Buttons/unchecked.dds", "", 20, 20, WidgetTypes.WIDGET_GENERAL, iI, -1, ButtonStyles.BUTTON_STYLE_LABEL)

			screen.attachControlToTableCell(tradeLabel,"TerrainTradeTable", screen.getTableNumRows("TerrainTradeTable")-1,1)
			screen.attachControlToTableCell(checkboxLabel,"TerrainTradeTable", screen.getTableNumRows("TerrainTradeTable")-1,2)

		screen.appendTableRow("TechEditTable")

		screen.attachLabel( "InnerTechInfoDetailsPanel", "AdvisorLabel", "    <font=3>Advisor Type:</font>")
		screen.attachControlToTableCell("AdvisorLabel","TechEditTable", screen.getTableNumRows("TechEditTable")-1,0)

		self.attachSlider(screen, "AI Weight", "AIWeight", -49, 49)
		self.attachSlider(screen, "AI Trade Modifier", "AITradeModifier", -49, 49)
		self.attachSlider(screen, "Research Cost", "ResearchCost", 0, 20000)
		
		screen.appendTableRow("TechEditTable")
		screen.attachLabel( "InnerTechInfoDetailsPanel", "EraLabel", "    <font=3>Era Type</font>:")
		screen.attachControlToTableCell("EraLabel","TechEditTable", 4,0)

		self.attachSlider(screen, "Feature Production Modifier", "FeatureProductionModifier", -49, 49)
		self.attachSlider(screen, "Trade Routes", "TradeRoutes", 0, 99)
		self.attachSlider(screen, "Worker Speed Modifier", "WorkerSpeedModifier", -49, 49)
		
		screen.appendTableRow("TechEditTable")
		screen.attachLabel( "InnerTechInfoDetailsPanel", "FirstFreeUnitClassLabel", "    <font=3>First Free Unit Class:</font>")
		screen.attachControlToTableCell("FirstFreeUnitClassLabel","TechEditTable", screen.getTableNumRows("TechEditTable")-1,0)

		self.attachSlider(screen, "Health", "Health", -49, 49)
		self.attachSlider(screen, "Happiness", "Happiness", -49, 49)
		self.attachSlider(screen, "First Free Techs", "FirstFreeTechs", 0, 99)
		self.attachSlider(screen, "Asset Value", "Asset", -49, 49)
		self.attachSlider(screen, "Power Value", "Power", -49, 49)
		
		self.attachCheckBox(screen, "Repeatable", "Repeat")
		self.attachCheckBox(screen, "Tradable", "Trade")
		self.attachCheckBox(screen, "Disable", "Disable")
		self.attachCheckBox(screen, "Goody Tech", "GoodyTech")
		self.attachCheckBox(screen, "Extra Sight Across Water", "ExtraWaterSeeFrom")
		self.attachCheckBox(screen, "Centers Map", "MapCentering")
		self.attachCheckBox(screen, "Reveals Map", "MapVisible")
		self.attachCheckBox(screen, "Enables Map Trading", "MapTrading")
		self.attachCheckBox(screen, "Enables Tech Trading", "TechTrading")
		self.attachCheckBox(screen, "Enables Gold Trading", "GoldTrading")
		self.attachCheckBox(screen, "Enables Open Borders", "OpenBordersTrading")
		self.attachCheckBox(screen, "Enables Defensive Pacts", "DefensivePactTrading")
		self.attachCheckBox(screen, "Enables Permanent Alliances", "PermanentAllianceTrading")
		self.attachCheckBox(screen, "Enables Vassal States", "VassalStateTrading")
		self.attachCheckBox(screen, "Enables Bridge Building", "BridgeBuilding")
		self.attachCheckBox(screen, "Farms Spread Irrigation", "InnerIrrigation")
		self.attachCheckBox(screen, "Build Farms Without Irrigation", "IgnoreIrrigation")
		self.attachCheckBox(screen, "Can Work Water Tiles", "WaterWork")
		

	def attachSlider(self, screen, szLabel, szName, iMin, iMax):
		screen.appendTableRow("TechEditTable")
		screen.attachLabel( "InnerTechInfoDetailsPanel", "%sLabel" %(szName), "    <font=3>%s:</font>" %(szLabel))
		screen.attachSlider("InnerTechInfoDetailsPanel", "%sSlider" %(szName), 0, 0, 150, 20, 0, iMin, iMax, WidgetTypes.WIDGET_GENERAL, -1, -1, false)
		screen.attachLabel( "InnerTechInfoDetailsPanel", "%sValue" %(szName), "<font=3>0</font>")

		screen.attachControlToTableCell("%sLabel" %(szName),"TechEditTable", screen.getTableNumRows("TechEditTable")-1,0)
		screen.attachControlToTableCell("%sSlider" %(szName),"TechEditTable", screen.getTableNumRows("TechEditTable")-1,1)
		screen.attachControlToTableCell("%sValue" %(szName),"TechEditTable", screen.getTableNumRows("TechEditTable")-1,2)
	
	
	def attachCheckBox(self, screen, szLabel, szName):
		screen.appendTableRow("TechEditTable")
		screen.attachLabel( "InnerTechInfoDetailsPanel", "%sLabel" %(szName), "    <font=3>%s:</font>" %(szLabel))
		screen.attachCheckBoxGFC("InnerTechInfoDetailsPanel", "%sButton" %(szName), "Art/Interface/Buttons/unchecked.dds", "", 20, 20, WidgetTypes.WIDGET_GENERAL, -1, -1, ButtonStyles.BUTTON_STYLE_LABEL)

		screen.attachControlToTableCell("%sLabel" %(szName),"TechEditTable", screen.getTableNumRows("TechEditTable")-1,0)
		screen.attachControlToTableCell("%sButton" %(szName),"TechEditTable", screen.getTableNumRows("TechEditTable")-1,1)
	
	def hideTech(self, iTech):
		# Get the screen
		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )

		screen.hide( "TechRecord" + str(iTech) )
		screen.hide( "TechID" + str(iTech) )
		
		screen.hide("TechInfoDetailsPanel")	
		screen.hide("TechInfoPanel")
		screen.hide("TechNamePanel")
		screen.hide("TechInfoName")
		screen.hide("techButton")
		screen.hide("DeleteTechButton")
		screen.hide("InnerTechInfoDetailsPanel")
		screen.hide("TechInfoClose")
		screen.hide("Maximize")
		screen.hide("Minimize")
		screen.hide("TechButtonID" + str(iTech))

		j = 0
		k = 0
		
		for j in range( gc.getDefineINT("NUM_AND_TECH_PREREQS") ):
			eTech = gc.getTechInfo(iTech).getPrereqAndTechs(j)
			if ( eTech > -1 ):
				screen.hide("TechPrereqID" + str((iTech * 1000) + j))

		j = 0
		k = 0
		
		for j in range(gc.getNumTechInfos()):
		
			if(gc.getTechInfo(j).isPrereqAndTech(iTech)):
				screen.hide("TechPrereqID" + str((j * 1000) + gc.getTechInfo(j).getPrereqAndTechIndex(iTech)))
			

		j = 0
		k = 0

		for j in range( gc.getNumUnitClassInfos() ):
			eLoopUnit = gc.getCivilizationInfo(gc.getGame().getActiveCivilizationType()).getCivilizationUnits(j)
			if (eLoopUnit != -1):
				if (gc.getUnitInfo(eLoopUnit).getPrereqAndTech() == iTech):
					screen.hide("Unit" + str(j))

		j = 0
		k = 0

		for j in range(gc.getNumBuildingClassInfos()):
			eLoopBuilding = gc.getCivilizationInfo(gc.getGame().getActiveCivilizationType()).getCivilizationBuildings(j)
			if (eLoopBuilding != -1):
				if (gc.getBuildingInfo(eLoopBuilding).getPrereqAndTech() == iTech):
					szBuildingButton = "Building" + str(j)
					screen.hide("Building" + str(j))		
			
			eLoopBuilding = gc.getBuildingClassInfo(j).getDefaultBuildingIndex()
			if (eLoopBuilding != -1):
				if (gc.getBuildingInfo(eLoopBuilding).getObsoleteTech() == iTech):
					# Add obsolete picture here...
					screen.hide( "Obsolete" + str(j) )
					screen.hide( "ObsoleteX" + str(j) )

		j = 0
		k = 0

		for j in range(gc.getNumBonusInfos()):
			if (gc.getBonusInfo(j).getTechObsolete() == iTech):
				screen.hide("ObsoleteBonus" + str(j))
				screen.hide("ObsoleteXBonus" + str(j))

			if (gc.getBonusInfo(j).getTechReveal() == iTech):
				screen.hide("BonusRevealButton" + str( ( iTech * 1000 ) + j ))
						
		j = 0
		k = 0

		# Obsolete Monastaries...
		for j in range (gc.getNumSpecialBuildingInfos()):
			if (gc.getSpecialBuildingInfo(j).getObsoleteTech() == iTech):
					# Add obsolete picture here...
					screen.hide("ObsoleteSpecial" + str(j))
					screen.hide("ObsoleteSpecialX" + str(j))

			if (gc.getSpecialBuildingInfo(j).getTechPrereq() == iTech):
				screen.hide("SpecialBuildingButton" + str( ( iTech * 1000 ) + j ))

		j = 0
		k = 0

		# Route movement change
		for j in range(gc.getNumRouteInfos()):
			if ( gc.getRouteInfo(j).getTechMovementChange(iTech) != 0 ):
				screen.hide("Move" + str(j))

		j = 0
		k = 0

		# Promotion Info
		for j in range( gc.getNumPromotionInfos() ):
			if ( gc.getPromotionInfo(j).getTechPrereq() == iTech ):
				screen.hide("Promotion" + str(iTech))
				
		# Free unit
		if ( gc.getTechInfo(iTech).getFirstFreeUnitClass() != UnitClassTypes.NO_UNITCLASS ):
			screen.hide("FreeUnit" + str(iTech))

		# Feature production modifier
		if ( gc.getTechInfo(iTech).getFeatureProductionModifier() != 0 ):
			screen.hide("FeatureProduction" + str(iTech))
		
		# Worker speed
		if ( gc.getTechInfo(iTech).getWorkerSpeedModifier() != 0 ):
			screen.hide("Worker" + str(iTech))

		# Trade Routes per City change
		if ( gc.getTechInfo(iTech).getTradeRoutes() != 0 ):
			screen.hide("TradeRoutes" + str(iTech))
		
		# Health Rate bonus from this tech...
		if ( gc.getTechInfo(iTech).getHealth() != 0 ):
			screen.hide("HealthRate" + str(iTech))

		# Happiness Rate bonus from this tech...
		if ( gc.getTechInfo(iTech).getHappiness() != 0 ):
			screen.hide("HappinessRate" + str(iTech))

		# Free Techs
		if ( gc.getTechInfo(iTech).getFirstFreeTechs() > 0 ):
			screen.hide("FreeTech" + str(iTech))

		# Line of Sight bonus...
		if ( gc.getTechInfo(iTech).isExtraWaterSeeFrom() ):
			screen.hide("LOS" + str(iTech))

		# Map Center Bonus...
		if ( gc.getTechInfo(iTech).isMapCentering() ):
			screen.hide("MapCenter" + str(iTech))
		
		if ( gc.getTechInfo(iTech).isMapVisible() ):
			screen.hide("MapReveal" + str(iTech))
				    
		# Map Trading
		if ( gc.getTechInfo(iTech).isMapTrading() == True ):
			screen.hide("MapTrade" + str(iTech))

		# Tech Trading
		if ( gc.getTechInfo(iTech).isTechTrading() ):
			screen.hide("TechTrade" + str(iTech))

		# Gold Trading
		if ( gc.getTechInfo(iTech).isGoldTrading() ):
			screen.hide("GoldTrade" + str(iTech))
	
		# Open Borders
		if ( gc.getTechInfo(iTech).isOpenBordersTrading() ):
			screen.hide("OpenBorders" + str(iTech))
		
		# Defensive Pact
		if ( gc.getTechInfo(iTech).isDefensivePactTrading() ):
			screen.hide("DefensivePact" + str(iTech))

		# Permanent Alliance
		if ( gc.getTechInfo(iTech).isPermanentAllianceTrading() ):
			screen.hide("PermanentAlliance" + str(iTech))

		# Vassal State
		if ( gc.getTechInfo(iTech).isVassalStateTrading() ):
			screen.hide("VassalState" + str(iTech))

		# Bridge Building
		if ( gc.getTechInfo(iTech).isBridgeBuilding() ):
			screen.hide("BuildBridge" + str(iTech))

		# Irrigation unlocked...
		if ( gc.getTechInfo(iTech).isIrrigation() ):
			screen.hide("Irrigation" + str(iTech))

		# Ignore Irrigation unlocked...
		if ( gc.getTechInfo(iTech).isIgnoreIrrigation() ):
			screen.hide("IgnoreIrrigation" + str(iTech))

		# Coastal Work unlocked...
		if ( gc.getTechInfo(iTech).isWaterWork() ):
			screen.hide("WaterWork" + str(iTech))

		j = 0
		k = 0

		# Improvements
		for j in range(gc.getNumBuildInfos()):
			bTechFound = 0;

			if (gc.getBuildInfo(j).getTechPrereq() == -1):
				bTechFound = 0
				for k in range(gc.getNumFeatureInfos()):
					if (gc.getBuildInfo(j).getFeatureTech(k) == iTech):
						bTechFound = 1
			else:
				if (gc.getBuildInfo(j).getTechPrereq() == iTech):
					bTechFound = 1

			if (bTechFound == 1):
				screen.hide("Improvement" + str( ( iTech * 1000 ) + j ))

		j = 0
		k = 0

		# Domain Extra Moves
		for j in range( DomainTypes.NUM_DOMAIN_TYPES ):
			if (gc.getTechInfo(iTech).getDomainExtraMoves(j) != 0):
				screen.hide("DomainExtraMoves" + str( ( iTech * 1000 ) + j ))
			
		j = 0
		k = 0

		# Adjustments
		for j in range( CommerceTypes.NUM_COMMERCE_TYPES ):
			if (gc.getTechInfo(iTech).isCommerceFlexible(j)):
				screen.hide("AdjustButton" + str( ( iTech * 1000 ) + j ))

		j = 0
		k = 0

		# Terrain opens up as a trade route
		for j in range( gc.getNumTerrainInfos() ):
			if (gc.getTechInfo(iTech).isTerrainTrade(j)):
				screen.hide("TerrainTradeButton" + str( ( iTech * 1000 ) + j ))
			
		j = 0
		k = 0
		
		# Yield change
		for j in range( gc.getNumImprovementInfos() ):
			bFound = False
			for k in range( YieldTypes.NUM_YIELD_TYPES ):
				if (gc.getImprovementInfo(j).getTechYieldChanges(iTech, k)):
					if ( bFound == False ):
						screen.hide("YieldChangeButton" + str( ( iTech * 1000 ) + j ))
						bFound = True
	
		j = 0
		k = 0

		# Civic options
		for j in range( gc.getNumCivicInfos() ):
			if (gc.getCivicInfo(j).getTechPrereq() == iTech):
				screen.hide("CivicRevealButton" + str( ( iTech * 1000 ) + j ))

		j = 0
		k = 0

		# Projects possible
		for j in range( gc.getNumProjectInfos() ):
			if (gc.getProjectInfo(j).getTechPrereq() == iTech):
				screen.hide("ProjectInfoButton" + str( ( iTech * 1000 ) + j ))

		j = 0
		k = 0

		# Processes possible
		for j in range( gc.getNumProcessInfos() ):
			if (gc.getProcessInfo(j).getTechPrereq() == iTech):
				screen.hide("ProcessInfoButton" + str( ( iTech * 1000 ) + j ))

		j = 0
		k = 0

		# Religions unlocked
		for j in range( gc.getNumReligionInfos() ):
			if ( gc.getReligionInfo(j).getTechPrereq() == iTech ):
				screen.hide("FoundReligionButton" + str( ( iTech * 1000 ) + j ))
		
		self.iOldSelectedTech = -1
		self.iSelectedTech = -1
		self.hideArrows(iTech)
			
	# Will hide the arrows
	def hideArrows (self, iTech):

		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )

		if( iTech != -1):
			for j in range(gc.getNumTechInfos()):
		
				if(gc.getTechInfo(j).isPrereqOrTech(iTech)):
					self.hideRedrawArrows(j, iTech)
			
		bFirst = 1
		
		j = 0
		
		for j in range( gc.getDefineINT("NUM_OR_TECH_PREREQS") ):

			eTech = gc.getTechInfo(iTech).getPrereqOrTechs(j)
				
			if ( eTech > -1 ):
				screen.hide( "%s_%s_X1" %(iTech, j))
				screen.hide( "%s_%s_CORNER1" %(iTech, j))
				screen.hide( "%s_%s_Y" %(iTech, j))
				screen.hide( "%s_%s_CORNER2" %(iTech, j))
				screen.hide( "%s_%s_X2" %(iTech, j))
				screen.hide( "%s_%s_HEAD" %(iTech, j))

			else:
				screen.hide( "%s_%s_X1" %(iTech, j))
				screen.hide( "%s_%s_CORNER1" %(iTech, j))
				screen.hide( "%s_%s_Y" %(iTech, j))
				screen.hide( "%s_%s_CORNER2" %(iTech, j))
				screen.hide( "%s_%s_X2" %(iTech, j))
				screen.hide( "%s_%s_HEAD" %(iTech, j))
		
		return
			
	# Will draw the arrows
	def hideRedrawArrows (self, iTech, iDeletedTech):
		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )
							
		j = 0
		
		for j in range( gc.getDefineINT("NUM_OR_TECH_PREREQS") ):
			
			eTech = gc.getTechInfo(iTech).getPrereqOrTechs(j)
				
			if(gc.getTechInfo(iTech).isPrereqOrTech(eTech) and eTech == iDeletedTech):
				screen.hide( "%s_%s_X1" %(iTech, j))
				screen.hide( "%s_%s_CORNER1" %(iTech, j))
				screen.hide( "%s_%s_Y" %(iTech, j))
				screen.hide( "%s_%s_CORNER2" %(iTech, j))
				screen.hide( "%s_%s_X2" %(iTech, j))
				screen.hide( "%s_%s_HEAD" %(iTech, j))

		return
					
			
	def placeTechs (self, iUpdatedTech = -1):
	

		iMaxX = 0
		iMaxY = 0

		hideList = []
		
		# If we are the Pitboss, we don't want to put up an interface at all
		if ( CyGame().isPitbossHost() ):
			return
			
		# Get the screen
		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )

	
		# Go through all the techs
		for i in range(gc.getNumTechInfos()):
			
			if(gc.getTechInfo(i).isDeleted()):
				continue

			if(iUpdatedTech != -1 and i != iUpdatedTech):
				continue
				
			# Create and place a tech in its proper location
			iX = 30 + ( (gc.getTechInfo(i).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
			iY = ( gc.getTechInfo(i).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5
			szTechRecord = "TechRecord" + str(i)
			
			if ( iMaxX < iX + self.getXStart() ):
				iMaxX = iX + self.getXStart()
			if ( iMaxY < iY + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT ) ):
				iMaxY = iY + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT )

			screen.attachPanelAt( "TechList", szTechRecord, u"", u"", True, False, PanelStyles.PANEL_STYLE_TECH, iX - 6, iY - 6, self.getXStart() + 6, 12 + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT ), WidgetTypes.WIDGET_EDIT_TECH, i, -1 )
			screen.setActivation( szTechRecord, ActivationTypes.ACTIVATE_MIMICPARENTFOCUS)
			screen.hide( szTechRecord )

			if(iUpdatedTech != -1 and iUpdatedTech == i):
				screen.setPanelColor(szTechRecord, 206, 65, 69)
			else:
				screen.setPanelColor(szTechRecord, 100, 104, 160)
			
			# screen.setPanelColor(szTechRecord, 100, 104, 160)

			szTechID = "TechID" + str(i)
			szTechString = "<font=1>"

			szTechString += gc.getTechInfo(i).getDescription()
			szTechString = szTechString + "    pos:(%s,%s)</font>" %(gc.getTechInfo(i).getGridX(), gc.getTechInfo(i).getGridY())
			screen.setTextAt( szTechID, "TechList", szTechString, CvUtil.FONT_LEFT_JUSTIFY, iX + 6 + X_INCREMENT, iY + 6, -0.1, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_EDIT_TECH, i, -1 )
			screen.setActivation( szTechID, ActivationTypes.ACTIVATE_MIMICPARENTFOCUS )

			szTechButtonID = "TechButtonID" + str(i)
			screen.addDDSGFCAt( szTechButtonID, "TechList", gc.getTechInfo(i).getButton(), iX + 6, iY + 6, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_EDIT_TECH, i, -1, False )

			fX = (BOX_INCREMENT_WIDTH * PIXEL_INCREMENT) - 8

			for j in range( gc.getDefineINT("NUM_AND_TECH_PREREQS") ):

				eTech = gc.getTechInfo(i).getPrereqAndTechs(j)

				if ( eTech > -1 ):

					fX = fX - X_INCREMENT

					iX = 30 + ( (gc.getTechInfo(i).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
					iY = ( gc.getTechInfo(i).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5

					szTechPrereqID = "TechPrereqID" + str((i * 1000) + j)
					screen.addDDSGFCAt( szTechPrereqID, "TechList", gc.getTechInfo(eTech).getButton(), iX + fX, iY + 6, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_TECH_PREPREQ, eTech, -1, False )
					screen.moveToFront(szTechPrereqID)
				else:
					szTechPrereqID = "TechPrereqID" + str((i * 1000) + j)
					screen.changeDDSGFC(szTechPrereqID,"")
				
			fX = X_START

			j = 0
			k = 0

			# Unlockable units...
			for j in range( gc.getNumUnitClassInfos() ):
				eLoopUnit = gc.getCivilizationInfo(gc.getGame().getActiveCivilizationType()).getCivilizationUnits(j)
				if (eLoopUnit != -1):
					if (gc.getUnitInfo(eLoopUnit).getPrereqAndTech() == i):
						szUnitButton = "Unit" + str(j)
						screen.addDDSGFCAt( szUnitButton, "TechList", gc.getUnitInfo(eLoopUnit).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_UNIT, eLoopUnit, 1, True )
						fX += X_INCREMENT

			j = 0
			k = 0

			# Unlockable Buildings...
			for j in range(gc.getNumBuildingClassInfos()):
				bTechFound = 0
				eLoopBuilding = gc.getCivilizationInfo(gc.getGame().getActiveCivilizationType()).getCivilizationBuildings(j)

				if (eLoopBuilding != -1):
					if (gc.getBuildingInfo(eLoopBuilding).getPrereqAndTech() == i):
						szBuildingButton = "Building" + str(j)
						screen.addDDSGFCAt( szBuildingButton, "TechList", gc.getBuildingInfo(eLoopBuilding).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BUILDING, eLoopBuilding, 1, True )
						fX += X_INCREMENT

			j = 0
			k = 0

			# Obsolete Buildings...
			for j in range(gc.getNumBuildingClassInfos()):
				eLoopBuilding = gc.getBuildingClassInfo(j).getDefaultBuildingIndex()
				if (eLoopBuilding != -1):
					if (gc.getBuildingInfo(eLoopBuilding).getObsoleteTech() == i):
						# Add obsolete picture here...
						szObsoleteButton = "Obsolete" + str(j)
						szObsoleteX = "ObsoleteX" + str(j)
						screen.addDDSGFCAt( szObsoleteButton, "TechList", gc.getBuildingInfo(eLoopBuilding).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE, eLoopBuilding, -1, False )
						screen.addDDSGFCAt( szObsoleteX, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_RED_X").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE, eLoopBuilding, -1, False )
						fX += X_INCREMENT
						
			j = 0
			k = 0

			# Obsolete Bonuses...
			for j in range(gc.getNumBonusInfos()):
				if (gc.getBonusInfo(j).getTechObsolete() == i):
					# Add obsolete picture here...
					szObsoleteButton = "ObsoleteBonus" + str(j)
					szObsoleteX = "ObsoleteXBonus" + str(j)
					screen.addDDSGFCAt( szObsoleteButton, "TechList", gc.getBonusInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE_BONUS, j, -1, False )
					screen.addDDSGFCAt( szObsoleteX, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_RED_X").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE_BONUS, j, -1, False )
					fX += X_INCREMENT
						
			j = 0
			k = 0

			# Obsolete Monastaries...
			for j in range (gc.getNumSpecialBuildingInfos()):
				if (gc.getSpecialBuildingInfo(j).getObsoleteTech() == i):
						# Add obsolete picture here...
						szObsoleteSpecialButton = "ObsoleteSpecial" + str(j)
						szObsoleteSpecialX = "ObsoleteSpecialX" + str(j)
						screen.addDDSGFCAt( szObsoleteSpecialButton, "TechList", gc.getSpecialBuildingInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE_SPECIAL, j, -1, False )
						screen.addDDSGFCAt( szObsoleteSpecialX, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_RED_X").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OBSOLETE_SPECIAL, j, -1, False )
						fX += X_INCREMENT

			j = 0
			k = 0

			# Route movement change
			for j in range(gc.getNumRouteInfos()):
				if ( gc.getRouteInfo(j).getTechMovementChange(i) != 0 ):
					szMoveButton = "Move" + str(j)
					screen.addDDSGFCAt( szMoveButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_MOVE_BONUS").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_MOVE_BONUS, i, -1, False )
					fX += X_INCREMENT

			j = 0
			k = 0

			# Promotion Info
			for j in range( gc.getNumPromotionInfos() ):
				if ( gc.getPromotionInfo(j).getTechPrereq() == i ):
					szPromotionButton = "Promotion" + str(i)
					screen.addDDSGFCAt( szPromotionButton, "TechList", gc.getPromotionInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_PROMOTION, j, -1, False )
					fX += X_INCREMENT

			j = 0
			k = 0

			# Free unit
			if ( gc.getTechInfo(i).getFirstFreeUnitClass() != UnitClassTypes.NO_UNITCLASS ):
				szFreeUnitButton = "FreeUnit" + str(i)
				screen.addDDSGFCAt( szFreeUnitButton, "TechList", gc.getUnitInfo(gc.getUnitClassInfo(gc.getTechInfo(i).getFirstFreeUnitClass()).getDefaultUnitIndex()).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_FREE_UNIT, gc.getUnitClassInfo(gc.getTechInfo(i).getFirstFreeUnitClass()).getDefaultUnitIndex(), i, False )
				fX += X_INCREMENT
			else:
				hideList.append("FreeUnit" + str(i))

			j = 0
			k = 0

			# Feature production modifier
			if ( gc.getTechInfo(i).getFeatureProductionModifier() != 0 ):
				szFeatureProductionButton = "FeatureProduction" + str(i)
				screen.addDDSGFCAt( szFeatureProductionButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_FEATURE_PRODUCTION").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_FEATURE_PRODUCTION, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("FeatureProduction" + str(i))
			
			j = 0
			k = 0

			# Worker speed
			if ( gc.getTechInfo(i).getWorkerSpeedModifier() != 0 ):
				szWorkerModifierButton = "Worker" + str(i)
				screen.addDDSGFCAt( szWorkerModifierButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_WORKER_SPEED").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_WORKER_RATE, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("Worker" + str(i))
			
			j = 0
			k = 0

			# Trade Routes per City change
			if ( gc.getTechInfo(i).getTradeRoutes() != 0 ):
				szTradeRouteButton = "TradeRoutes" + str(i)
				screen.addDDSGFCAt( szTradeRouteButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_TRADE_ROUTES").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_TRADE_ROUTES, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("TradeRoutes" + str(i))
			
			j = 0
			k = 0

			# Health Rate bonus from this tech...
			if ( gc.getTechInfo(i).getHealth() != 0 ):
				szHealthRateButton = "HealthRate" + str(i)
				screen.addDDSGFCAt( szHealthRateButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_HEALTH").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_HEALTH_RATE, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("HealthRate" + str(i))
			
			j = 0
			k = 0

			# Happiness Rate bonus from this tech...
			if ( gc.getTechInfo(i).getHappiness() != 0 ):
				szHappinessRateButton = "HappinessRate" + str(i)
				screen.addDDSGFCAt( szHappinessRateButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_HAPPINESS").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_HAPPINESS_RATE, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("HappinessRate" + str(i))
			
			j = 0
			k = 0

			# Free Techs
			if ( gc.getTechInfo(i).getFirstFreeTechs() > 0 ):
				szFreeTechButton = "FreeTech" + str(i)
				screen.addDDSGFCAt( szFreeTechButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_FREETECH").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_FREE_TECH, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("FreeTech" + str(i))
			
			j = 0
			k = 0

			# Line of Sight bonus...
			if ( gc.getTechInfo(i).isExtraWaterSeeFrom() ):
				szLOSButton = "LOS" + str(i)
				screen.addDDSGFCAt( szLOSButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_LOS").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_LOS_BONUS, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("LOS" + str(i))
			
			j = 0
			k = 0

			# Map Center Bonus...
			if ( gc.getTechInfo(i).isMapCentering() ):
				szMapCenterButton = "MapCenter" + str(i)
				screen.addDDSGFCAt( szMapCenterButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_MAPCENTER").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_MAP_CENTER, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("MapCenter" + str(i))
			
			
			j = 0
			k = 0

			# Map Reveal...
			if ( gc.getTechInfo(i).isMapVisible() ):
				szMapRevealButton = "MapReveal" + str(i)
				screen.addDDSGFCAt( szMapRevealButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_MAPREVEAL").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_MAP_REVEAL, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("MapReveal" + str(i))
					    
			j = 0
			k = 0

			# Map Trading
			if ( gc.getTechInfo(i).isMapTrading() == True ):
				szMapTradeButton = "MapTrade" + str(i)
				screen.addDDSGFCAt( szMapTradeButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_MAPTRADING").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_MAP_TRADE, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("MapTrade" + str(i))
			
			j = 0
			k = 0

			# Tech Trading
			if ( gc.getTechInfo(i).isTechTrading() ):
				szTechTradeButton = "TechTrade" + str(i)
				screen.addDDSGFCAt( szTechTradeButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_TECHTRADING").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_TECH_TRADE, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("TechTrade" + str(i))
			
			j = 0
			k = 0

			# Gold Trading
			if ( gc.getTechInfo(i).isGoldTrading() ):
				szGoldTradeButton = "GoldTrade" + str(i)
				screen.addDDSGFCAt( szGoldTradeButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_GOLDTRADING").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_GOLD_TRADE, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("GoldTrade" + str(i))
			
			j = 0
			k = 0

			# Open Borders
			if ( gc.getTechInfo(i).isOpenBordersTrading() ):
				szOpenBordersButton = "OpenBorders" + str(i)
				screen.addDDSGFCAt( szOpenBordersButton , "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_OPENBORDERS").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_OPEN_BORDERS, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("OpenBorders" + str(i))
			
			j = 0
			k = 0

			# Defensive Pact
			if ( gc.getTechInfo(i).isDefensivePactTrading() ):
				szDefensivePactButton = "DefensivePact" + str(i)
				screen.addDDSGFCAt( szDefensivePactButton , "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_DEFENSIVEPACT").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_DEFENSIVE_PACT, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("DefensivePact" + str(i))
			
			j = 0
			k = 0

			# Permanent Alliance
			if ( gc.getTechInfo(i).isPermanentAllianceTrading() ):
				szPermanentAllianceButton = "PermanentAlliance" + str(i)
				screen.addDDSGFCAt( szPermanentAllianceButton , "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_PERMALLIANCE").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_PERMANENT_ALLIANCE, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("PermanentAlliance" + str(i))
			
			j = 0
			k = 0

			# Vassal States
			if ( gc.getTechInfo(i).isVassalStateTrading() ):
				szVassalStateButton = "VassalState" + str(i)
				screen.addDDSGFCAt( szVassalStateButton , "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_VASSAL").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_VASSAL_STATE, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("VassalState" + str(i))

			j = 0
			k = 0

			# Bridge Building
			if ( gc.getTechInfo(i).isBridgeBuilding() ):
				szBuildBridgeButton = "BuildBridge" + str(i)
				screen.addDDSGFCAt( szBuildBridgeButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_BRIDGEBUILDING").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_BUILD_BRIDGE, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("BuildBridge" + str(i))
			
			j = 0
			k = 0

			# Irrigation unlocked...
			if ( gc.getTechInfo(i).isIrrigation() ):
				szIrrigationButton = "Irrigation" + str(i)
				screen.addDDSGFCAt( szIrrigationButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_IRRIGATION").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_IRRIGATION, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("Irrigation" + str(i))
			
			j = 0
			k = 0

			# Ignore Irrigation unlocked...
			if ( gc.getTechInfo(i).isIgnoreIrrigation() ):
				szIgnoreIrrigationButton = "IgnoreIrrigation" + str(i)
				screen.addDDSGFCAt( szIgnoreIrrigationButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_NOIRRIGATION").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_IGNORE_IRRIGATION, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("IgnoreIrrigation" + str(i))
			
			j = 0
			k = 0

			# Coastal Work unlocked...
			if ( gc.getTechInfo(i).isWaterWork() ):
				szWaterWorkButton = "WaterWork" + str(i)
				screen.addDDSGFCAt( szWaterWorkButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_WATERWORK").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_WATER_WORK, i, -1, False )
				fX += X_INCREMENT
			else:
				hideList.append("WaterWork" + str(i))
			
			j = 0
			k = 0

			# Improvements
			for j in range(gc.getNumBuildInfos()):
				bTechFound = 0;

				if (gc.getBuildInfo(j).getTechPrereq() == -1):
					bTechFound = 0
					for k in range(gc.getNumFeatureInfos()):
						if (gc.getBuildInfo(j).getFeatureTech(k) == i):
							bTechFound = 1
				else:
					if (gc.getBuildInfo(j).getTechPrereq() == i):
						bTechFound = 1

				if (bTechFound == 1):
					szImprovementButton = "Improvement" + str( ( i * 1000 ) + j )
					screen.addDDSGFCAt( szImprovementButton, "TechList", gc.getBuildInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_IMPROVEMENT, i, j, False )
					fX += X_INCREMENT

			j = 0
			k = 0

			# Domain Extra Moves
			for j in range( DomainTypes.NUM_DOMAIN_TYPES ):
				if (gc.getTechInfo(i).getDomainExtraMoves(j) != 0):
					szDomainExtraMovesButton = "DomainExtraMoves" + str( ( i * 1000 ) + j )
					screen.addDDSGFCAt( szDomainExtraMovesButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_WATERMOVES").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_DOMAIN_EXTRA_MOVES, i, j, False )
					fX += X_INCREMENT
				else:
					hideList.append("DomainExtraMoves" + str( ( i * 1000 ) + j ))
				
			j = 0
			k = 0

			# Adjustments
			for j in range( CommerceTypes.NUM_COMMERCE_TYPES ):
				if (gc.getTechInfo(i).isCommerceFlexible(j)):
					szAdjustButton = "AdjustButton" + str( ( i * 1000 ) + j )
					if ( j == CommerceTypes.COMMERCE_CULTURE ):
						szFileName = ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_CULTURE").getPath()
					else:
						szFileName = ArtFileMgr.getInterfaceArtInfo("INTERFACE_GENERAL_QUESTIONMARK").getPath()
					screen.addDDSGFCAt( szAdjustButton, "TechList", szFileName, iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_ADJUST, i, j, False )
					fX += X_INCREMENT
				else:
					hideList.append("AdjustButton" + str( ( i * 1000 ) + j ))

			j = 0
			k = 0

			# Terrain opens up as a trade route
			for j in range( gc.getNumTerrainInfos() ):
				if (gc.getTechInfo(i).isTerrainTrade(j)):
					szTerrainTradeButton = "TerrainTradeButton" + str( ( i * 1000 ) + j )
					screen.addDDSGFCAt( szTerrainTradeButton, "TechList", ArtFileMgr.getInterfaceArtInfo("INTERFACE_TECH_WATERTRADE").getPath(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_TERRAIN_TRADE, i, j, False )
					fX += X_INCREMENT
				else:
					hideList.append("TerrainTradeButton" + str( ( i * 1000 ) + j ))
				
			j = 0
			k = 0

			# Special buildings like monestaries...
			for j in range( gc.getNumSpecialBuildingInfos() ):
				if (gc.getSpecialBuildingInfo(j).getTechPrereq() == i):
					szSpecialBuilding = "SpecialBuildingButton" + str( ( i * 1000 ) + j )
					screen.addDDSGFCAt( szSpecialBuilding, "TechList", gc.getSpecialBuildingInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_SPECIAL_BUILDING, i, j, False )
					fX += X_INCREMENT

			j = 0
			k = 0
			
			# Yield change
			for j in range( gc.getNumImprovementInfos() ):
				bFound = False
				for k in range( YieldTypes.NUM_YIELD_TYPES ):
					if (gc.getImprovementInfo(j).getTechYieldChanges(i, k)):
						if ( bFound == False ):
							szYieldChange = "YieldChangeButton" + str( ( i * 1000 ) + j )
							screen.addDDSGFCAt( szYieldChange, "TechList", gc.getImprovementInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_YIELD_CHANGE, i, j, False )
							fX += X_INCREMENT
							bFound = True
		
			j = 0
			k = 0

			# Bonuses revealed
			for j in range( gc.getNumBonusInfos() ):
				if (gc.getBonusInfo(j).getTechReveal() == i):
					szBonusReveal = "BonusRevealButton" + str( ( i * 1000 ) + j )
					screen.addDDSGFCAt( szBonusReveal, "TechList", gc.getBonusInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_BONUS_REVEAL, i, j, False )
					fX += X_INCREMENT

			j = 0
			k = 0

			# Civic options
			for j in range( gc.getNumCivicInfos() ):
				if (gc.getCivicInfo(j).getTechPrereq() == i):
					szCivicReveal = "CivicRevealButton" + str( ( i * 1000 ) + j )
					screen.addDDSGFCAt( szCivicReveal, "TechList", gc.getCivicInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_CIVIC_REVEAL, i, j, False )
					fX += X_INCREMENT

			j = 0
			k = 0

			# Projects possible
			for j in range( gc.getNumProjectInfos() ):
				if (gc.getProjectInfo(j).getTechPrereq() == i):
					szProjectInfo = "ProjectInfoButton" + str( ( i * 1000 ) + j )
					screen.addDDSGFCAt( szProjectInfo, "TechList", gc.getProjectInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_PROJECT, j, 1, False )
					fX += X_INCREMENT

			j = 0
			k = 0

			# Processes possible
			for j in range( gc.getNumProcessInfos() ):
				if (gc.getProcessInfo(j).getTechPrereq() == i):
					szProcessInfo = "ProcessInfoButton" + str( ( i * 1000 ) + j )
					screen.addDDSGFCAt( szProcessInfo, "TechList", gc.getProcessInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_PROCESS_INFO, i, j, False )
					fX += X_INCREMENT

			j = 0
			k = 0

			# Religions unlocked
			for j in range( gc.getNumReligionInfos() ):
				if ( gc.getReligionInfo(j).getTechPrereq() == i ):
					szFoundReligion = "FoundReligionButton" + str( ( i * 1000 ) + j )
					screen.addDDSGFCAt( szFoundReligion, "TechList", gc.getReligionInfo(j).getButton(), iX + fX, iY + Y_ROW, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_FOUND_RELIGION, i, j, False )
					fX += X_INCREMENT
					
			screen.show( szTechRecord )
		
		for szButton in hideList:
			screen.changeDDSGFC(szButton,"")
			
		screen.attachPanelAt( "TechList", "filler", u"", u"", True, False, PanelStyles.PANEL_STYLE_TECH, iMaxX+300, -100, self.getXStart() + 6, 12 + ( BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT ), WidgetTypes.WIDGET_EDIT_TECH, i, -1 )
		screen.setViewMin( "TechList", iMaxX + 20, iMaxY + 20 )
		screen.show( "TechList" )
		screen.setFocus( "TechList" )

	def updateTechButton(self):
		# Get the screen
		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )				
		screen.changeImageButton("techButton", gc.getTechInfo(self.iSelectedTech).getButton())

	def updateTechName(self):
		# Get the screen
		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )				
		szText = u"<font=4>%s</font>" %(gc.getTechInfo(self.iSelectedTech).getDescription())
		screen.setText( "TechInfoName", "TechInfoPanel", szText, CvUtil.FONT_CENTER_JUSTIFY, (1024/2)+((1024/2)/2), 55+(55/4)+6+15, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_CHANGE_TECH_NAME, self.iSelectedTech, -1 )

	# Will update the tech records based on color, researching, researched, queued, etc.
	def updateTechRecords (self, bForce):


		if(self.iSelectedTech == -1):
			return
		

		# If we are the Pitboss, we don't want to put up an interface at all
		if ( CyGame().isPitbossHost() ):
			return
			
		# Get the screen
		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )				

		szTechRecord = "TechRecord" + str(self.iSelectedTech)
		szOldTechRecord = "TechRecord" + str(self.iOldSelectedTech)

		if(self.iSelectedTech != -1):
			screen.setPanelColor(szTechRecord, 206, 65, 69)
	
		if(self.iOldSelectedTech != -1):
			screen.setPanelColor(szOldTechRecord, 100, 104, 160)
	
		if(self.iSelectedTech != -1):
			screen.hide("TechInfoDetailsPanel")
		
			screen.show("TechInfoPanel")
			screen.show("TechNamePanel")
			screen.show("techButton")
			screen.show("DeleteTechButton")
			screen.show("InnerTechInfoDetailsPanel")
			screen.show("TechInfoClose")
			
			
			fX = (BOX_INCREMENT_WIDTH * PIXEL_INCREMENT) - 8

			for j in range( gc.getDefineINT("NUM_AND_TECH_PREREQS") ):

				eTech = gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(j)

				if ( eTech > -1 ):

					fX = fX - X_INCREMENT

					iX = 30 + ( (gc.getTechInfo(self.iSelectedTech).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
					iY = ( gc.getTechInfo(self.iSelectedTech).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5

					szTechPrereqID = "TechPrereqID" + str((self.iSelectedTech * 1000) + j)
					screen.addDDSGFCAt( szTechPrereqID, "TechList", gc.getTechInfo(eTech).getButton(), iX + fX, iY + 6, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_TECH_PREPREQ, eTech, -1, False )
					screen.moveToFront(szTechPrereqID)
								
			szText = u"<font=4>%s</font>" %(gc.getTechInfo(self.iSelectedTech).getDescription())
			screen.setText( "TechInfoName", "TechInfoPanel", szText, CvUtil.FONT_CENTER_JUSTIFY, (1024/2)+((1024/2)/2), 55+(55/4)+6+15, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_CHANGE_TECH_NAME, self.iSelectedTech, -1 )

			if(not self.bMinimized):
				screen.setButtonGFC( "Minimize", u"", "", (1024/2)+((1024/2)/2)+((1024/2)/2)-60, 55+(55/4)+12, 20, 20, WidgetTypes.WIDGET_GENERAL, -1, -1, ButtonStyles.BUTTON_STYLE_CITY_MINUS )
			else:
				screen.setButtonGFC( "Maximize", u"", "", (1024/2)+((1024/2)/2)+((1024/2)/2)-60, 55+(55/4)+12, 20, 20, WidgetTypes.WIDGET_GENERAL, -1, -1, ButtonStyles.BUTTON_STYLE_CITY_PLUS )
			
			
			screen.setImageButton("techButton", gc.getTechInfo(self.iSelectedTech).getButton(),  (1024/2), 55+(55/4)+6, 64, 64, WidgetTypes.WIDGET_CHANGE_TECH_IMAGE, self.iSelectedTech, -1)
			screen.setImageButton("DeleteTechButton", ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_CANCEL").getPath(), (1024/2)+((1024/2)/2)+((1024/2)/2)-60-6, 55+(55/4)+40, 32, 32, WidgetTypes.WIDGET_DELETE_TECH, self.iSelectedTech, -1)
	
			szLocation = "(%s , %s)" %(gc.getTechInfo(self.iSelectedTech).getGridX(), gc.getTechInfo(self.iSelectedTech).getGridY())
			screen.attachLabel( "MiddleCenterLocationPanel", "MiddleCenterLocationValue", szLocation)

			screen.attachDropDownBoxGFC("InnerTechInfoDetailsPanel", "AdvisorDDL", false)
			
			for i in range (gc.getNumAdvisorInfos()):
				if(i == gc.getTechInfo(self.iSelectedTech).getAdvisorType()):
					screen.addPullDownString( "AdvisorDDL", gc.getAdvisorInfo(i).getDescription(), i, i, True )
				else:
					screen.addPullDownString( "AdvisorDDL", gc.getAdvisorInfo(i).getDescription(), i, i, False )
			
			screen.attachDropDownBoxGFC("InnerTechInfoDetailsPanel", "EraDDL", false)
			
			for i in range (gc.getNumEraInfos()):
				if(i == gc.getTechInfo(self.iSelectedTech).getEra()):
					screen.addPullDownString( "EraDDL", gc.getEraInfo(i).getDescription(), i, i, True )
				else:
					screen.addPullDownString( "EraDDL", gc.getEraInfo(i).getDescription(), i, i, False )
						
						
			screen.attachDropDownBoxGFC("InnerTechInfoDetailsPanel", "FirstFreeUnitClassDDL", false)
			
			if(gc.getTechInfo(self.iSelectedTech).getFirstFreeUnitClass() == -1):
				screen.addPullDownString( "FirstFreeUnitClassDDL", "None", 0, 0, True )
			else:
				screen.addPullDownString( "FirstFreeUnitClassDDL", "None", 0, 0, False )

			for i in range (gc.getNumUnitClassInfos()):
				if(i == gc.getTechInfo(self.iSelectedTech).getFirstFreeUnitClass()):
					screen.addPullDownString( "FirstFreeUnitClassDDL", gc.getUnitClassInfo(i).getDescription(), (i-1), (i-1), True )
				else:
					screen.addPullDownString( "FirstFreeUnitClassDDL", gc.getUnitClassInfo(i).getDescription(), (i-1), (i-1), False )
											
			for iI in range(DomainTypes.NUM_DOMAIN_TYPES):
				sliderLabel = str("%sExtraMovesSlider" %(gc.getDomainInfo(iI).getDescription().replace(" ","")))
				valueLabel = str("%sExtraMovesValue" %(gc.getDomainInfo(iI).getDescription().replace(" ","")))

				screen.attachSlider("InnerTechInfoDetailsPanel", sliderLabel, 0, 0, 150, 20, gc.getTechInfo(self.iSelectedTech).getDomainExtraMoves(iI), -49, 49, WidgetTypes.WIDGET_GENERAL, iI, -1, false)
				screen.attachLabel( "InnerTechInfoDetailsPanel", valueLabel, "<font=3>%s</font>" %(gc.getTechInfo(self.iSelectedTech).getDomainExtraMoves(iI)))
				screen.attachControlToTableCell(sliderLabel,"DomainExtraMovesTable", iI,2)
				screen.attachControlToTableCell(valueLabel,"DomainExtraMovesTable", iI,3)

			for iI in range(gc.getNumFlavorTypes()):
				sliderLabel = str("%sValuesSlider" %(gc.getFlavorTypes(iI).replace(" ","")))
				valueLabel = str("%sValuesValue" %(gc.getFlavorTypes(iI).replace(" ","")))

				screen.attachSlider("InnerTechInfoDetailsPanel", sliderLabel, 0, 0, 150, 20, gc.getTechInfo(self.iSelectedTech).getFlavorValue(iI), -49, 49, WidgetTypes.WIDGET_GENERAL, iI, -1, false)
				screen.attachLabel( "InnerTechInfoDetailsPanel", valueLabel, "<font=3>%s</font>" %(gc.getTechInfo(self.iSelectedTech).getFlavorValue(iI)))

				screen.attachControlToTableCell(sliderLabel,"FlavorValuesTable", iI,2)
				screen.attachControlToTableCell(valueLabel,"FlavorValuesTable", iI,3)
				
			self.drawPrereqOrTechInfo()

			self.drawPrereqAndTechInfo()
			

			for iI in range(CommerceTypes.NUM_COMMERCE_TYPES):

				checkboxLabel = "CommerceFlexible%s" %(iI)

				if(gc.getTechInfo(self.iSelectedTech).isCommerceFlexible(iI)):
					screen.attachCheckBoxGFC("InnerTechInfoDetailsPanel", checkboxLabel, "Art/Interface/Buttons/checked.dds", "", 20, 20, WidgetTypes.WIDGET_GENERAL, iI, -1, ButtonStyles.BUTTON_STYLE_LABEL)
				else:
					screen.attachCheckBoxGFC("InnerTechInfoDetailsPanel", checkboxLabel, "Art/Interface/Buttons/unchecked.dds", "", 20, 20, WidgetTypes.WIDGET_GENERAL, iI, -1, ButtonStyles.BUTTON_STYLE_LABEL)

				screen.attachControlToTableCell(checkboxLabel,"CommerceFlexibleTable", iI,2)
				screen.setState(checkboxLabel, gc.getTechInfo(self.iSelectedTech).isCommerceFlexible(iI))
				

			for iI in range(gc.getNumTerrainInfos()):

				checkboxLabel = "TerrainTrade%s" %(iI)

				if(gc.getTechInfo(self.iSelectedTech).isTerrainTrade(iI)):
					screen.attachCheckBoxGFC("InnerTechInfoDetailsPanel", checkboxLabel, "Art/Interface/Buttons/checked.dds", "", 20, 20, WidgetTypes.WIDGET_GENERAL, iI, -1, ButtonStyles.BUTTON_STYLE_LABEL)
				else:
					screen.attachCheckBoxGFC("InnerTechInfoDetailsPanel", checkboxLabel, "Art/Interface/Buttons/unchecked.dds", "", 20, 20, WidgetTypes.WIDGET_GENERAL, iI, -1, ButtonStyles.BUTTON_STYLE_LABEL)

				screen.attachControlToTableCell(checkboxLabel,"TerrainTradeTable", iI,2)
				screen.setState(checkboxLabel, gc.getTechInfo(self.iSelectedTech).isTerrainTrade(iI))
				

			iCurrentRow = 0
			screen.attachControlToTableCell("AdvisorDDL","TechEditTable", iCurrentRow,1)
			
			iCurrentRow += 1
			self.updateSlider(screen, "AIWeight", gc.getTechInfo(self.iSelectedTech).getAIWeight, -49, 49, iCurrentRow)
						
			iCurrentRow += 1
			self.updateSlider(screen, "AITradeModifier", gc.getTechInfo(self.iSelectedTech).getAITradeModifier, -49, 49, iCurrentRow)

			iCurrentRow += 1
			self.updateSlider(screen, "ResearchCost", gc.getTechInfo(self.iSelectedTech).getResearchCost, 0, 20000, iCurrentRow)
			
			iCurrentRow += 1
			screen.attachControlToTableCell("EraDDL","TechEditTable", iCurrentRow,1)
			
			iCurrentRow += 1
			self.updateSlider(screen, "FeatureProductionModifier", gc.getTechInfo(self.iSelectedTech).getFeatureProductionModifier, -49, 49, iCurrentRow)

			iCurrentRow += 1
			self.updateSlider(screen, "TradeRoutes", gc.getTechInfo(self.iSelectedTech).getTradeRoutes, 0, 99, iCurrentRow)

			iCurrentRow += 1
			self.updateSlider(screen, "WorkerSpeedModifier", gc.getTechInfo(self.iSelectedTech).getWorkerSpeedModifier, -49, 49, iCurrentRow)

			iCurrentRow += 1
			screen.attachControlToTableCell("FirstFreeUnitClassDDL","TechEditTable", iCurrentRow,1)
				
			iCurrentRow += 1
			self.updateSlider(screen, "Health", gc.getTechInfo(self.iSelectedTech).getHealth, -49, 49, iCurrentRow)
				
			iCurrentRow += 1
			self.updateSlider(screen, "Happiness", gc.getTechInfo(self.iSelectedTech).getHappiness, -49, 49, iCurrentRow)
			
			iCurrentRow += 1
			self.updateSlider(screen, "FirstFreeTechs", gc.getTechInfo(self.iSelectedTech).getFirstFreeTechs, 0, 99, iCurrentRow)

			iCurrentRow += 1
			self.updateSlider(screen, "Asset", gc.getTechInfo(self.iSelectedTech).getAssetValue, -49, 49, iCurrentRow)

			iCurrentRow += 1
			self.updateSlider(screen, "Power", gc.getTechInfo(self.iSelectedTech).getPowerValue, -49, 49, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "Repeat", gc.getTechInfo(self.iSelectedTech).isRepeat, iCurrentRow)
			
			iCurrentRow += 1
			self.updateCheckbox(screen, "Trade", gc.getTechInfo(self.iSelectedTech).isTrade, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "Disable", gc.getTechInfo(self.iSelectedTech).isDisable, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "GoodyTech", gc.getTechInfo(self.iSelectedTech).isGoodyTech, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "ExtraWaterSeeFrom", gc.getTechInfo(self.iSelectedTech).isExtraWaterSeeFrom, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "MapCentering", gc.getTechInfo(self.iSelectedTech).isMapCentering, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "MapVisible", gc.getTechInfo(self.iSelectedTech).isMapVisible, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "MapTrading", gc.getTechInfo(self.iSelectedTech).isMapTrading, iCurrentRow)
		
			iCurrentRow += 1
			self.updateCheckbox(screen, "TechTrading", gc.getTechInfo(self.iSelectedTech).isTechTrading, iCurrentRow)

			iCurrentRow += 1	
			self.updateCheckbox(screen, "GoldTrading", gc.getTechInfo(self.iSelectedTech).isGoldTrading, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "OpenBordersTrading", gc.getTechInfo(self.iSelectedTech).isOpenBordersTrading, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "DefensivePactTrading", gc.getTechInfo(self.iSelectedTech).isDefensivePactTrading, iCurrentRow)
						
			iCurrentRow += 1
			self.updateCheckbox(screen, "PermanentAllianceTrading", gc.getTechInfo(self.iSelectedTech).isPermanentAllianceTrading, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "VassalStateTrading", gc.getTechInfo(self.iSelectedTech).isVassalStateTrading, iCurrentRow)
						
			iCurrentRow += 1
			self.updateCheckbox(screen, "BridgeBuilding", gc.getTechInfo(self.iSelectedTech).isBridgeBuilding, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "InnerIrrigation", gc.getTechInfo(self.iSelectedTech).isIrrigation, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "IgnoreIrrigation", gc.getTechInfo(self.iSelectedTech).isIgnoreIrrigation, iCurrentRow)

			iCurrentRow += 1
			self.updateCheckbox(screen, "WaterWork", gc.getTechInfo(self.iSelectedTech).isWaterWork, iCurrentRow)
				
				
			screen.setTableColumnHeader("TechEditTable", 0, "", 230)
			

			if(self.bMinimized):
				screen.hide("InnerTechInfoDetailsPanel")
				screen.hide("TechInfoDetailsPanel")
				screen.hide("TechInfoClose")				
			else:
				screen.show("TechInfoDetailsPanel")

	def updateSlider(self, screen, szName, pFunction, iMin, iMax, iRow):
		screen.attachSlider("InnerTechInfoDetailsPanel", "%sSlider" %(szName), 0, 0, 150, 20, pFunction(), iMin, iMax, WidgetTypes.WIDGET_GENERAL, -1, -1, false)
		screen.attachLabel( "InnerTechInfoDetailsPanel", "%sValue" %(szName), "<font=3>%s</font>" %(pFunction()))

		screen.attachControlToTableCell("%sSlider" %(szName),"TechEditTable", iRow,1)
		screen.attachControlToTableCell("%sValue" %(szName),"TechEditTable", iRow,2)

	def updateCheckbox(self, screen, szName, pFunction, iRow):
		if(pFunction()):
			screen.attachCheckBoxGFC("InnerTechInfoDetailsPanel", "%sButton" %(szName), "Art/Interface/Buttons/checked.dds", "", 20, 20, WidgetTypes.WIDGET_GENERAL, -1, -1, ButtonStyles.BUTTON_STYLE_LABEL)
		else:
			screen.attachCheckBoxGFC("InnerTechInfoDetailsPanel", "%sButton" %(szName), "Art/Interface/Buttons/unchecked.dds", "", 20, 20, WidgetTypes.WIDGET_GENERAL, -1, -1, ButtonStyles.BUTTON_STYLE_LABEL)

		screen.setState("%sButton" %(szName), pFunction())
	
		screen.attachControlToTableCell("%sLabel" %(szName),"TechEditTable", iRow,0)
		screen.attachControlToTableCell("%sButton" %(szName),"TechEditTable", iRow,1)
	
	def drawPrereqOrTechInfo(self):
		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )
		
		screen.attachPanel("MainPrereqOrTechsPanel", "SubPrereqOrTechsPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("SubPrereqOrTechsPanel", "Dummy1PrereqOrTechsPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("SubPrereqOrTechsPanel", "PrereqOrTechsPanel", "", "", True, false, PanelStyles.PANEL_STYLE_MAIN_BLACK25)
		screen.attachPanel("SubPrereqOrTechsPanel", "Dummy2PrereqOrTechsPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		for i in range(8):
			screen.attachPanel("SubPrereqOrTechsPanel", "PrereqOrTechsDummy%sPanel" %(i), "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		for iI in range (gc.getDefineINT("NUM_OR_TECH_PREREQS")):
			if(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI) != TechTypes.NO_TECH):
			
				objTechInfo = gc.getTechInfo(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI))
				screen.attachPanel("PrereqOrTechsPanel", "SubPrereqOrTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI))), "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
				screen.attachPanel("SubPrereqOrTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI))), "DummyPrereqOrTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI))), "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
				screen.attachPanel("SubPrereqOrTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI))), "InnerPrereqOrTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI))), "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

				screen.attachImageButton("InnerPrereqOrTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI))), "PrereqOrTech%dButton" %(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI)), gc.getTechInfo(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI)).getButton(), GenericButtonSizes.BUTTON_SIZE_24, WidgetTypes.WIDGET_GENERAL, -1, -1, false)
				screen.attachLabel( "InnerPrereqOrTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI))), "PrereqOrTech%sLabel" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI))), "    <font=3>%s</font>" %(objTechInfo.getDescription()))
				screen.attachImageButton("InnerPrereqOrTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI))), "DeletePrereqOrTech%d" %(gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI)), ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_CANCEL").getPath(), GenericButtonSizes.BUTTON_SIZE_24, WidgetTypes.WIDGET_REMOVE_OR_PREREQ_TECH, gc.getTechInfo(self.iSelectedTech).getPrereqOrTechs(iI), self.iSelectedTech, false)

		screen.enable("AddPrereqOrTechDDL", true)
		screen.enable("AddPrereqOrTechText", true)

		screen.attachDropDownBoxGFC("AddPrereqOrTechPanel", "AddPrereqOrTechDDL", false)
		screen.attachTextGFC("AddPrereqOrTechPanel", "AddPrereqOrTechText", "Add", FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
		screen.attachPanel("AddPrereqOrTechPanel", "AddPrereqOrTechDummy1", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
					

		techKeyList = []
		techHash = {}	
				
		for i in range (gc.getNumTechInfos()):

			if(gc.getTechInfo(i).isDeleted()):
				continue

			techKeyList.append(gc.getTechInfo(i).getDescription())
			techHash[gc.getTechInfo(i).getDescription()] = i
			
		techKeyList.sort()

		for szKey in techKeyList:
		
			if(techHash[szKey] == self.iSelectedTech):
				continue
			
			if(gc.getTechInfo(self.iSelectedTech).isPrereqOrTech(techHash[szKey])):
				continue

			if(gc.getTechInfo(self.iSelectedTech).isPrereqAndTech(techHash[szKey])):
				continue

			if(not gc.getTechInfo(self.iSelectedTech).isValidTechPrereq(techHash[szKey])):
				continue

			screen.addPullDownString( "AddPrereqOrTechDDL", szKey, techHash[szKey], techHash[szKey], False )

		screen.enable("AddPrereqOrTechDDL", gc.getTechInfo(self.iSelectedTech).canAddPrereqOrTech())
		screen.enable("AddPrereqOrTechText", gc.getTechInfo(self.iSelectedTech).canAddPrereqOrTech())


	def drawPrereqAndTechInfo(self):
		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )

		screen.attachPanel("MainPrereqAndTechsPanel", "SubPrereqAndTechsPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("SubPrereqAndTechsPanel", "Dummy1PrereqAndTechsPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		screen.attachPanel("SubPrereqAndTechsPanel", "PrereqAndTechsPanel", "", "", True, false, PanelStyles.PANEL_STYLE_MAIN_BLACK25)
		screen.attachPanel("SubPrereqAndTechsPanel", "Dummy2PrereqAndTechsPanel", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

		for i in range(8):
			screen.attachPanel("SubPrereqAndTechsPanel", "PrereqAndTechsDummy%sPanel" %(i), "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
		
		for iI in range (gc.getDefineINT("NUM_AND_TECH_PREREQS")):
			if(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI) != TechTypes.NO_TECH):
			
				objTechInfo = gc.getTechInfo(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI))
				screen.attachPanel("PrereqAndTechsPanel", "SubPrereqAndTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI))), "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
				screen.attachPanel("SubPrereqAndTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI))), "DummyPrereqAndTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI))), "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
				screen.attachPanel("SubPrereqAndTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI))), "InnerPrereqAndTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI))), "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)

				screen.attachImageButton("InnerPrereqAndTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI))), "PrereqAndTech%dButton" %(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI)), gc.getTechInfo(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI)).getButton(), GenericButtonSizes.BUTTON_SIZE_24, WidgetTypes.WIDGET_GENERAL, -1, -1, false)
				screen.attachLabel( "InnerPrereqAndTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI))), "PrereqAndTech%sLabel" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI))), "    <font=3>%s</font>" %(objTechInfo.getDescription()))
				screen.attachImageButton("InnerPrereqAndTech%s" %(str(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI))), "DeletePrereqAndTech%d" %(gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI)), ArtFileMgr.getInterfaceArtInfo("INTERFACE_BUTTONS_CANCEL").getPath(), GenericButtonSizes.BUTTON_SIZE_24, WidgetTypes.WIDGET_REMOVE_AND_PREREQ_TECH, gc.getTechInfo(self.iSelectedTech).getPrereqAndTechs(iI), self.iSelectedTech, false)

		
		screen.enable("AddPrereqAndTechDDL", true)
		screen.enable("AddPrereqAndTechText", true)

		screen.attachDropDownBoxGFC("AddPrereqAndTechPanel", "AddPrereqAndTechDDL", false)
		screen.attachTextGFC("AddPrereqAndTechPanel", "AddPrereqAndTechText", "Add", FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
		screen.attachPanel("AddPrereqAndTechPanel", "AddPrereqAndTechDummy1", "", "", false, false, PanelStyles.PANEL_STYLE_EMPTY)
					
		techKeyList = []
		techHash = {}	
				
		for i in range (gc.getNumTechInfos()):

			if(gc.getTechInfo(i).isDeleted()):
				continue

			techKeyList.append(gc.getTechInfo(i).getDescription())
			techHash[gc.getTechInfo(i).getDescription()] = i
			
		techKeyList.sort()
		
		for szKey in techKeyList:
		
			if(techHash[szKey] == self.iSelectedTech):
				continue
			
			if(gc.getTechInfo(self.iSelectedTech).isPrereqOrTech(techHash[szKey])):
				continue

			if(gc.getTechInfo(self.iSelectedTech).isPrereqAndTech(techHash[szKey])):
				continue
			
			if(not gc.getTechInfo(self.iSelectedTech).isValidTechPrereq(techHash[szKey])):
				continue

			screen.addPullDownString( "AddPrereqAndTechDDL", szKey, techHash[szKey], techHash[szKey], False )
					
					
	# Will draw the arrows
	def redrawArrows (self, iUpdatedTech):


		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )

		iLoop = 0
		
		ARROW_X = ArtFileMgr.getInterfaceArtInfo("ARROW_X").getPath()
		ARROW_Y = ArtFileMgr.getInterfaceArtInfo("ARROW_Y").getPath()
		ARROW_MXMY = ArtFileMgr.getInterfaceArtInfo("ARROW_MXMY").getPath()
		ARROW_XY = ArtFileMgr.getInterfaceArtInfo("ARROW_XY").getPath()
		ARROW_MXY = ArtFileMgr.getInterfaceArtInfo("ARROW_MXY").getPath()
		ARROW_XMY = ArtFileMgr.getInterfaceArtInfo("ARROW_XMY").getPath()
		ARROW_HEAD = ArtFileMgr.getInterfaceArtInfo("ARROW_HEAD").getPath()
					
		bFirst = 1

		fX = (BOX_INCREMENT_WIDTH * PIXEL_INCREMENT) - 8

		j = 0
		
		for j in range( gc.getDefineINT("NUM_OR_TECH_PREREQS") ):

			eTech = gc.getTechInfo(iUpdatedTech).getPrereqOrTechs(j)
				
			if ( eTech > -1 ):

				iX = 24 + ( (gc.getTechInfo(eTech).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
				iY = ( gc.getTechInfo(eTech).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5
				
				# j is the pre-req, i is the tech...
				xDiff = gc.getTechInfo(iUpdatedTech).getGridX() - gc.getTechInfo(eTech).getGridX()
				yDiff = gc.getTechInfo(iUpdatedTech).getGridY() - gc.getTechInfo(eTech).getGridY()

				screen.addDDSGFCAt( "%s_%s_X1" %(iUpdatedTech, j), "TechList", ARROW_X, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
				screen.addDDSGFCAt( "%s_%s_CORNER1" %(iUpdatedTech, j), "TechList", ARROW_XY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
				screen.addDDSGFCAt( "%s_%s_Y" %(iUpdatedTech, j), "TechList", ARROW_Y, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
				screen.addDDSGFCAt( "%s_%s_CORNER2" %(iUpdatedTech, j), "TechList", ARROW_XMY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
				screen.addDDSGFCAt( "%s_%s_X2" %(iUpdatedTech, j), "TechList", ARROW_X, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
				screen.addDDSGFCAt( "%s_%s_HEAD" %(iUpdatedTech, j), "TechList", ARROW_HEAD, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )

				if (yDiff == 0):
					screen.addDDSGFCAt( "%s_%s_X1" %(iUpdatedTech, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(3), self.getWidth(xDiff), 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_HEAD" %(iUpdatedTech, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )

					screen.addDDSGFCAt( "%s_%s_CORNER1" %(iUpdatedTech, j), "TechList", ARROW_XY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_Y" %(iUpdatedTech, j), "TechList", ARROW_Y, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_CORNER2" %(iUpdatedTech, j), "TechList", ARROW_XMY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_X2" %(iUpdatedTech, j), "TechList", ARROW_X, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )

				elif (yDiff < 0):
					if ( yDiff == -6 ):
						screen.addDDSGFCAt( "%s_%s_X1" %(iUpdatedTech, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(1), self.getWidth(xDiff) / 2, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER1" %(iUpdatedTech, j), "TechList", ARROW_XY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_Y" %(iUpdatedTech, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1) + 8 - self.getHeight(yDiff, 0), 8, self.getHeight(yDiff, 0) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER2" %(iUpdatedTech, j), "TechList", ARROW_XMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1) - self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_X2" %(iUpdatedTech, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1) - self.getHeight(yDiff, 0), ( self.getWidth(xDiff) / 2 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_HEAD" %(iUpdatedTech, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(1) - self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					elif ( yDiff == -2 and xDiff == 2 ):
						screen.addDDSGFCAt( "%s_%s_X1" %(iUpdatedTech, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(2), self.getWidth(xDiff) * 5 / 6, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER1" %(iUpdatedTech, j), "TechList", ARROW_XY, iX + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_Y" %(iUpdatedTech, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2) + 8 - self.getHeight(yDiff, 3), 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER2" %(iUpdatedTech, j), "TechList", ARROW_XMY, iX + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_X2" %(iUpdatedTech, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), ( self.getWidth(xDiff) / 6 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_HEAD" %(iUpdatedTech, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					else:
						screen.addDDSGFCAt( "%s_%s_X1" %(iUpdatedTech, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(2), self.getWidth(xDiff) / 2, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER1" %(iUpdatedTech, j), "TechList", ARROW_XY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_Y" %(iUpdatedTech, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2) + 8 - self.getHeight(yDiff, 3), 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER2" %(iUpdatedTech, j), "TechList", ARROW_XMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_X2" %(iUpdatedTech, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), ( self.getWidth(xDiff) / 2 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_HEAD" %(iUpdatedTech, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
				elif (yDiff > 0):
					if ( yDiff == 2 and xDiff == 2):
						screen.addDDSGFCAt( "%s_%s_X1" %(iUpdatedTech, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(4), self.getWidth(xDiff) / 6, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER1" %(iUpdatedTech, j), "TechList", ARROW_MXMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_Y" %(iUpdatedTech, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4) + 8, 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER2" %(iUpdatedTech, j), "TechList", ARROW_MXY, iX + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_X2" %(iUpdatedTech, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), ( self.getWidth(xDiff) * 5 / 6 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_HEAD" %(iUpdatedTech, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					elif ( yDiff == 4 and xDiff == 1):
						screen.addDDSGFCAt( "%s_%s_X1" %(iUpdatedTech, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(5), self.getWidth(xDiff) / 3, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER1" %(iUpdatedTech, j), "TechList", ARROW_MXMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_Y" %(iUpdatedTech, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5) + 8, 8, self.getHeight(yDiff, 0) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER2" %(iUpdatedTech, j), "TechList", ARROW_MXY, iX + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5) + self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_x2" %(iUpdatedTech, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5) + self.getHeight(yDiff, 0), ( self.getWidth(xDiff) * 2 / 3 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_HEAD" %(iUpdatedTech, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(5) + self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					else:
						screen.addDDSGFCAt( "%s_%s_X1" %(iUpdatedTech, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(4), self.getWidth(xDiff) / 2, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER1" %(iUpdatedTech, j), "TechList", ARROW_MXMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_Y" %(iUpdatedTech, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4) + 8, 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER2" %(iUpdatedTech, j), "TechList", ARROW_MXY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_X2" %(iUpdatedTech, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), ( self.getWidth(xDiff) / 2 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_HEAD" %(iUpdatedTech, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
				else:
					screen.addDDSGFCAt( "%s_%s_X1" %(iUpdatedTech, j), "TechList", ARROW_X, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_CORNER1" %(iUpdatedTech, j), "TechList", ARROW_XY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_Y" %(iUpdatedTech, j), "TechList", ARROW_Y, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_CORNER2" %(iUpdatedTech, j), "TechList", ARROW_XMY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_X2" %(iUpdatedTech, j), "TechList", ARROW_X, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_HEAD" %(iUpdatedTech, j), "TechList", ARROW_HEAD, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
				
		return
				
					
	# Will draw the arrows
#	def drawArrows (self, iUpdatedTech = -1):
	def drawArrows (self, iTech):


		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )

		iLoop = 0
		self.nWidgetCount = 0
		
		ARROW_X = ArtFileMgr.getInterfaceArtInfo("ARROW_X").getPath()
		ARROW_Y = ArtFileMgr.getInterfaceArtInfo("ARROW_Y").getPath()
		ARROW_MXMY = ArtFileMgr.getInterfaceArtInfo("ARROW_MXMY").getPath()
		ARROW_XY = ArtFileMgr.getInterfaceArtInfo("ARROW_XY").getPath()
		ARROW_MXY = ArtFileMgr.getInterfaceArtInfo("ARROW_MXY").getPath()
		ARROW_XMY = ArtFileMgr.getInterfaceArtInfo("ARROW_XMY").getPath()
		ARROW_HEAD = ArtFileMgr.getInterfaceArtInfo("ARROW_HEAD").getPath()

		
		for i in range(gc.getNumTechInfos()):

			if(gc.getTechInfo(i).isDeleted()):
				continue
			
			if( iTech != -1 and iTech != i):
				continue
				
			if( iTech != -1):		
				for j in range(gc.getNumTechInfos()):
			
					if(gc.getTechInfo(j).isDeleted()):
						continue
				
					if(gc.getTechInfo(j).isPrereqOrTech(iTech)):
						self.redrawArrows(j)						
												
						
			bFirst = 1

			fX = (BOX_INCREMENT_WIDTH * PIXEL_INCREMENT) - 8

			for j in range( gc.getDefineINT("NUM_AND_TECH_PREREQS") ):

				eTech = gc.getTechInfo(i).getPrereqAndTechs(j)

				if ( eTech > -1 ):

					fX = fX - X_INCREMENT

					iX = 30 + ( (gc.getTechInfo(i).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
					iY = ( gc.getTechInfo(i).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5

					szTechPrereqID = "TechPrereqID" + str((i * 1000) + j)
					screen.addDDSGFCAt( szTechPrereqID, "TechList", gc.getTechInfo(eTech).getButton(), iX + fX, iY + 6, TEXTURE_SIZE, TEXTURE_SIZE, WidgetTypes.WIDGET_HELP_TECH_PREPREQ, eTech, -1, False )
					screen.moveToFront(szTechPrereqID)
					#szTechPrereqBorderID = "TechPrereqBorderID" + str((i * 1000) + j)
					#screen.addDDSGFCAt( szTechPrereqBorderID, "TechList", ArtFileMgr.getInterfaceArtInfo("TECH_TREE_BUTTON_BORDER").getPath(), iX + fX + 4, iY + 22, 32, 32, WidgetTypes.WIDGET_HELP_TECH_PREPREQ, eTech, -1, False )

			j = 0
			
			for j in range( gc.getDefineINT("NUM_OR_TECH_PREREQS") ):

				eTech = gc.getTechInfo(i).getPrereqOrTechs(j)
					
				if ( eTech > -1 ):

					iX = 24 + ( (gc.getTechInfo(eTech).getGridX() - 1) * ( ( BOX_INCREMENT_X_SPACING + BOX_INCREMENT_WIDTH ) * PIXEL_INCREMENT ) )
					iY = ( gc.getTechInfo(eTech).getGridY() - 1 ) * ( BOX_INCREMENT_Y_SPACING * PIXEL_INCREMENT ) + 5
					
					# j is the pre-req, i is the tech...
					xDiff = gc.getTechInfo(i).getGridX() - gc.getTechInfo(eTech).getGridX()
					yDiff = gc.getTechInfo(i).getGridY() - gc.getTechInfo(eTech).getGridY()

					screen.addDDSGFCAt( "%s_%s_X1" %(iTech, j), "TechList", ARROW_X, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_CORNER1" %(iTech, j), "TechList", ARROW_XY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_Y" %(iTech, j), "TechList", ARROW_Y, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_CORNER2" %(iTech, j), "TechList", ARROW_XMY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_X2" %(iTech, j), "TechList", ARROW_X, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_HEAD" %(iTech, j), "TechList", ARROW_HEAD, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )

					if (yDiff == 0):
						screen.addDDSGFCAt( "%s_%s_X1" %(i, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(3), self.getWidth(xDiff), 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_HEAD" %(i, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )

						screen.addDDSGFCAt( "%s_%s_CORNER1" %(i, j), "TechList", ARROW_XY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_Y" %(i, j), "TechList", ARROW_Y, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_CORNER2" %(i, j), "TechList", ARROW_XMY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						screen.addDDSGFCAt( "%s_%s_X2" %(i, j), "TechList", ARROW_X, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )

					elif (yDiff < 0):
						if ( yDiff == -6 ):
							screen.addDDSGFCAt( "%s_%s_X1" %(i, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(1), self.getWidth(xDiff) / 2, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER1" %(i, j), "TechList", ARROW_XY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_Y" %(i, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1) + 8 - self.getHeight(yDiff, 0), 8, self.getHeight(yDiff, 0) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER2" %(i, j), "TechList", ARROW_XMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1) - self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_X2" %(i, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(1) - self.getHeight(yDiff, 0), ( self.getWidth(xDiff) / 2 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_HEAD" %(i, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(1) - self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						elif ( yDiff == -2 and xDiff == 2 ):
							screen.addDDSGFCAt( "%s_%s_X1" %(i, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(2), self.getWidth(xDiff) * 5 / 6, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER1" %(i, j), "TechList", ARROW_XY, iX + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_Y" %(i, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2) + 8 - self.getHeight(yDiff, 3), 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER2" %(i, j), "TechList", ARROW_XMY, iX + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_X2" %(i, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) * 5 / 6 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), ( self.getWidth(xDiff) / 6 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_HEAD" %(i, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						else:
							screen.addDDSGFCAt( "%s_%s_X1" %(i, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(2), self.getWidth(xDiff) / 2, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER1" %(i, j), "TechList", ARROW_XY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_Y" %(i, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2) + 8 - self.getHeight(yDiff, 3), 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER2" %(i, j), "TechList", ARROW_XMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_X2" %(i, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(2) - self.getHeight(yDiff, 3), ( self.getWidth(xDiff) / 2 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_HEAD" %(i, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(2) - self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					elif (yDiff > 0):
						if ( yDiff == 2 and xDiff == 2):
							screen.addDDSGFCAt( "%s_%s_X1" %(i, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(4), self.getWidth(xDiff) / 6, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER1" %(i, j), "TechList", ARROW_MXMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_Y" %(i, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4) + 8, 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER2" %(i, j), "TechList", ARROW_MXY, iX + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_X2" %(i, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 6 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), ( self.getWidth(xDiff) * 5 / 6 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_HEAD" %(i, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						elif ( yDiff == 4 and xDiff == 1):
							screen.addDDSGFCAt( "%s_%s_X1" %(i, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(5), self.getWidth(xDiff) / 3, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER1" %(i, j), "TechList", ARROW_MXMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_Y" %(i, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5) + 8, 8, self.getHeight(yDiff, 0) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER2" %(i, j), "TechList", ARROW_MXY, iX + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5) + self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_x2" %(i, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 3 ), iY + self.getYStart(5) + self.getHeight(yDiff, 0), ( self.getWidth(xDiff) * 2 / 3 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_HEAD" %(i, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(5) + self.getHeight(yDiff, 0), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
						else:
							screen.addDDSGFCAt( "%s_%s_X1" %(i, j), "TechList", ARROW_X, iX + self.getXStart(), iY + self.getYStart(4), self.getWidth(xDiff) / 2, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER1" %(i, j), "TechList", ARROW_MXMY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_Y" %(i, j), "TechList", ARROW_Y, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4) + 8, 8, self.getHeight(yDiff, 3) - 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_CORNER2" %(i, j), "TechList", ARROW_MXY, iX + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_X2" %(i, j), "TechList", ARROW_X, iX + 8 + self.getXStart() + ( self.getWidth(xDiff) / 2 ), iY + self.getYStart(4) + self.getHeight(yDiff, 3), ( self.getWidth(xDiff) / 2 ) - 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
							screen.addDDSGFCAt( "%s_%s_HEAD" %(i, j), "TechList", ARROW_HEAD, iX + self.getXStart() + self.getWidth(xDiff), iY + self.getYStart(4) + self.getHeight(yDiff, 3), 8, 8, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
				else:
					screen.addDDSGFCAt( "%s_%s_X1" %(iTech, j), "TechList", ARROW_X, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_CORNER1" %(iTech, j), "TechList", ARROW_XY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_Y" %(iTech, j), "TechList", ARROW_Y, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_CORNER2" %(iTech, j), "TechList", ARROW_XMY, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_X2" %(iTech, j), "TechList", ARROW_X, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )
					screen.addDDSGFCAt( "%s_%s_HEAD" %(iTech, j), "TechList", ARROW_HEAD, 0, 0, 0, 0, WidgetTypes.WIDGET_GENERAL, -1, -1, False )

					
		return

	def TechRecord (self, inputClass):
		return 0

	# Clicked the parent?
	def ParentClick (self, inputClass):
		return 0
								
	def addTech(self, strTechName):
		
		strTechType = "TECH_" + strTechName.replace(" ","_").upper()
				
		if(gc.getTechInfo(gc.getInfoTypeForString(strTechType)) == None):
			gc.addTechInfo(strTechType, strTechName)
		else:
			gc.getTechInfo(gc.getInfoTypeForString(strTechType)).init()

		gc.getTechInfo(gc.getInfoTypeForString(strTechType)).setGridX(1)
		gc.getTechInfo(gc.getInfoTypeForString(strTechType)).setGridY(1)
		gc.getTechInfo(gc.getInfoTypeForString(strTechType)).setButton("Art/Interface/Buttons/ReplaceMe.dds")
		self.iSelectedTech = gc.getInfoTypeForString(strTechType)

		self.placeTechs()
		self.updateTechRecords(true)
	
	def deleteTech(self, iTech):
	
		self.hideTech(iTech)
		gc.deleteTechInfo(iTech)

			
						
	# Will handle the input for this screen...
	def handleInput (self, inputClass):
		# Get the screen
		screen = CyGInterfaceScreen( "TechTreeEditor", CvScreenEnums.TECH_TREE_EDITOR )

		
		' Calls function mapped in TechTreeEditorInputMap'
		# only get from the map if it has the key
	
		#screen.setText( "TopPanelDebugMsg", "TopPanel", 
		#			"NC: %s | FN: %s | BT: %s %s| DATA: %s | DATA1: %s | DATA2: %s" %(inputClass.getNotifyCode(), inputClass.getFunctionName(), inputClass.getButtonType(), (inputClass.getButtonType()==WidgetTypes.WIDGET_EDIT_TECH), inputClass.getData(), inputClass.getData1(), inputClass.getData2())
		#			, CvUtil.FONT_RIGHT_JUSTIFY, 1010, 20, -10, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
	
		#screen.setText( "TopPanelDebugMsg", "TopPanel", 
		#			""
		#			, CvUtil.FONT_RIGHT_JUSTIFY, 1010, 20, -10, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

		"""
		self.deleteTech(gc.getInfoTypeForString("TECH_POLYTHEISM"));
		self.deleteTech(gc.getInfoTypeForString("TECH_PRIESTHOOD"));
		self.deleteTech(gc.getInfoTypeForString("TECH_MYSTICISM"));
		"""

		
		if(inputClass.getFunctionName() == "AddTech"):

			
			popup = PyPopup.PyPopup(CvUtil.EventAddTech, EventContextTypes.EVENTCONTEXT_ALL)
			popup.setHeaderString(localText.getText("TXT_KEY_ADD_TECH", ()))
			popup.setBodyString(localText.getText("TXT_KEY_NEW_TECH_NAME", ()))
			popup.createEditBox("",0)
			popup.launch()

			return 1

		if(inputClass.getFunctionName() == "DeleteTechButton"):

			self.deleteTech(self.iSelectedTech)

			return 1
			
		if(inputClass.getFunctionName() == "TechInfoName"):

			popup = PyPopup.PyPopup(CvUtil.EventChangeTechName, EventContextTypes.EVENTCONTEXT_ALL)
			popup.setHeaderString(localText.getText("TXT_KEY_CHANGE_TECH_NAME", (gc.getTechInfo(self.iSelectedTech).getText(),)))
			popup.setBodyString(localText.getText("TXT_KEY_NEW_TECH_NAME", ()))
			popup.createEditBox(gc.getTechInfo(self.iSelectedTech).getText(),0)
			popup.setUserData((self.iSelectedTech, self.iSelectedTech ))
			popup.launch()
			return 1
			
		if(inputClass.getFunctionName() == "techButton"):

			popup = PyPopup.PyPopup(CvUtil.EventChangeTechImage, EventContextTypes.EVENTCONTEXT_ALL)
			popup.setHeaderString(localText.getText("TXT_KEY_CHANGE_TECH_IMAGE", (gc.getTechInfo(self.iSelectedTech).getDescription(),)))
			popup.setBodyString(localText.getText("TXT_KEY_NEW_TECH_IMAGE", ()))
			popup.createEditBox(gc.getTechInfo(self.iSelectedTech).getButton(),0)
			popup.setUserData((self.iSelectedTech, self.iSelectedTech ))
			popup.launch()
			return 1

		if(inputClass.getFunctionName() == "TechTreeEditorSave"):
			#screen.setText( "TopPanelDebugMsg", "TopPanel", 
			#			"NC: %s | FN: %s | BT: %s %s| DATA: %s | DATA1: %s | DATA2: %s" %(inputClass.getNotifyCode(), inputClass.getFunctionName(), inputClass.getButtonType(), (inputClass.getButtonType()==WidgetTypes.WIDGET_EDIT_TECH), inputClass.getData(), inputClass.getData1(), inputClass.getData2())
			#			, CvUtil.FONT_RIGHT_JUSTIFY, 1010, 20, -10, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		
			if(gc.hasTechInfosChanged()):
				TechInfoWriter.TechInfoWriter().printTechs()
						
			return 1
			
			
		if(inputClass.getFunctionName() == "TerrainTrade"):
			if(screen.getCheckBoxState("TerrainTrade%s" %(inputClass.getData1()))):
				screen.changeImageButton("TerrainTrade%s" %(inputClass.getData1()), "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("TerrainTrade%s" %(inputClass.getData1()), "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setTerrainTrade(inputClass.getData1(), screen.getCheckBoxState("TerrainTrade%s" %(inputClass.getData1())))
			self.placeTechs(self.iSelectedTech)
					
			return 1

		if(inputClass.getFunctionName() == "CommerceFlexible"):

			if(screen.getCheckBoxState("CommerceFlexible%s" %(inputClass.getData1()))):
				screen.changeImageButton("CommerceFlexible%s" %(inputClass.getData1()), "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("CommerceFlexible%s" %(inputClass.getData1()), "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setCommerceFlexible(inputClass.getData1(), screen.getCheckBoxState("CommerceFlexible%s" %(inputClass.getData1())))
			self.placeTechs(self.iSelectedTech)
					
			return 1
			
		if(inputClass.getFunctionName() == "AddPrereqOrTechText"):
			#screen.setText( "TopPanelDebugMsg", "TopPanel", 
			#			"%s %s" %(screen.getSelectedPullDownID("AddPrereqOrTechDDL"), gc.getTechInfo(screen.getPullDownData("AddPrereqOrTechDDL", screen.getSelectedPullDownID("AddPrereqOrTechDDL"))).getDescription() )
			# 			, CvUtil.FONT_RIGHT_JUSTIFY, 1010, 20, -10, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

			if(gc.getTechInfo(self.iSelectedTech).addPrereqOrTech(screen.getPullDownData("AddPrereqOrTechDDL", screen.getSelectedPullDownID("AddPrereqOrTechDDL")))):

				self.drawPrereqOrTechInfo()

				self.drawPrereqAndTechInfo()

			self.drawArrows(self.iSelectedTech)

			screen.enable("AddPrereqOrTechDDL", gc.getTechInfo(self.iSelectedTech).canAddPrereqOrTech())
			screen.enable("AddPrereqOrTechText", gc.getTechInfo(self.iSelectedTech).canAddPrereqOrTech())
			
					
			return 1
						
		if(inputClass.getFunctionName() == "DeletePrereqOrTech" and inputClass.getData1() >= 0 and inputClass.getData2() >= 0 and inputClass.getButtonType() == WidgetTypes.WIDGET_REMOVE_OR_PREREQ_TECH):
			#screen.setText( "TopPanelDebugMsg", "TopPanel", 
			#			"NC: %s | FN: %s | BT: %s %s| DATA: %s | DATA1: %s | DATA2: %s" %(inputClass.getNotifyCode(), inputClass.getFunctionName(), inputClass.getButtonType(), (inputClass.getButtonType()==WidgetTypes.WIDGET_EDIT_TECH), inputClass.getData(), inputClass.getData1(), inputClass.getData2())
			#			, CvUtil.FONT_RIGHT_JUSTIFY, 1010, 20, -10, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
			gc.getTechInfo(self.iSelectedTech).removePrereqOrTech(inputClass.getData1())
			#self.placeTechs(self.iSelectedTech)
			#self.updateTechRecords(false)
			
			self.drawPrereqOrTechInfo()

			self.drawPrereqAndTechInfo()

			self.drawArrows(self.iSelectedTech)

			screen.enable("AddPrereqOrTechDDL", gc.getTechInfo(self.iSelectedTech).canAddPrereqOrTech())
			screen.enable("AddPrereqOrTechText", gc.getTechInfo(self.iSelectedTech).canAddPrereqOrTech())

			return 1					
					
		if(inputClass.getFunctionName() == "AddPrereqAndTechText"):
			#screen.setText( "TopPanelDebugMsg", "TopPanel", 
			#			"%s|%s|%s" %(screen.getSelectedPullDownID("AddPrereqAndTechDDL"), 
			#					gc.getTechInfo(screen.getPullDownData("AddPrereqAndTechDDL", screen.getSelectedPullDownID("AddPrereqAndTechDDL"))).getDescription(),
			#					screen.getPullDownData("AddPrereqAndTechDDL", screen.getSelectedPullDownID("AddPrereqAndTechDDL")))
			#			, CvUtil.FONT_RIGHT_JUSTIFY, 1010, 20, -10, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

		
			if(gc.getTechInfo(self.iSelectedTech).addPrereqAndTech(screen.getPullDownData("AddPrereqAndTechDDL", screen.getSelectedPullDownID("AddPrereqAndTechDDL")))):

				self.drawPrereqOrTechInfo()

				self.drawPrereqAndTechInfo()
	
				self.placeTechs(self.iSelectedTech)

			screen.enable("AddPrereqAndTechDDL", gc.getTechInfo(self.iSelectedTech).canAddPrereqAndTech())
			screen.enable("AddPrereqAndTechText", gc.getTechInfo(self.iSelectedTech).canAddPrereqAndTech())
			
			return 1
						
		if(inputClass.getFunctionName() == "DeletePrereqAndTech" and inputClass.getData1() >= 0 and inputClass.getData2() >= 0 and inputClass.getButtonType() == WidgetTypes.WIDGET_REMOVE_AND_PREREQ_TECH):
			#screen.setText( "TopPanelDebugMsg", "TopPanel", 
			#			"NC: %s | FN: %s | BT: %s %s| DATA: %s | DATA1: %s | DATA2: %s" %(inputClass.getNotifyCode(), inputClass.getFunctionName(), inputClass.getButtonType(), (inputClass.getButtonType()==WidgetTypes.WIDGET_EDIT_TECH), inputClass.getData(), inputClass.getData1(), inputClass.getData2())
			#			, CvUtil.FONT_RIGHT_JUSTIFY, 1010, 20, -10, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
			
			gc.getTechInfo(self.iSelectedTech).removePrereqAndTech(inputClass.getData1())

			self.placeTechs(self.iSelectedTech)
			#self.updateTechRecords(false)
			
			self.drawPrereqOrTechInfo()

			self.drawPrereqAndTechInfo()


			screen.enable("AddPrereqAndTechDDL", gc.getTechInfo(self.iSelectedTech).canAddPrereqAndTech())
			screen.enable("AddPrereqAndTechText", gc.getTechInfo(self.iSelectedTech).canAddPrereqAndTech())

			return 1					
						
		if(inputClass.getFunctionName() == "RepeatButton"):
			if(screen.getCheckBoxState("RepeatButton")):
				screen.changeImageButton("RepeatButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("RepeatButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setRepeat(screen.getCheckBoxState("RepeatButton"))
			
			return 1
			
		if(inputClass.getFunctionName() == "TradeButton"):
			if(screen.getCheckBoxState("TradeButton")):
				screen.changeImageButton("TradeButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("TradeButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setTrade(screen.getCheckBoxState("TradeButton"))
			
			return 1			
			
		if(inputClass.getFunctionName() == "DisableButton"):
			if(screen.getCheckBoxState("DisableButton")):
				screen.changeImageButton("DisableButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("DisableButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setDisable(screen.getCheckBoxState("DisableButton"))
			
			return 1
					
					
		if(inputClass.getFunctionName() == "GoodyTechButton"):
			if(screen.getCheckBoxState("GoodyTechButton")):
				screen.changeImageButton("GoodyTechButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("GoodyTechButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setGoodyTech(screen.getCheckBoxState("GoodyTechButton"))
			
			return 1
			
		if(inputClass.getFunctionName() == "ExtraWaterSeeFromButton"):
			if(screen.getCheckBoxState("ExtraWaterSeeFromButton")):
				screen.changeImageButton("ExtraWaterSeeFromButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("ExtraWaterSeeFromButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setExtraWaterSeeFrom(screen.getCheckBoxState("ExtraWaterSeeFromButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1			
			
		if(inputClass.getFunctionName() == "MapCenteringButton"):
			if(screen.getCheckBoxState("MapCenteringButton")):
				screen.changeImageButton("MapCenteringButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("MapCenteringButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setMapCentering(screen.getCheckBoxState("MapCenteringButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1
			
		if(inputClass.getFunctionName() == "MapVisibleButton"):
			if(screen.getCheckBoxState("MapVisibleButton")):
				screen.changeImageButton("MapVisibleButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("MapVisibleButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setMapVisible(screen.getCheckBoxState("MapVisibleButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1

		if(inputClass.getFunctionName() == "MapTradingButton"):
			if(screen.getCheckBoxState("MapTradingButton")):
				screen.changeImageButton("MapTradingButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("MapTradingButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setMapTrading(screen.getCheckBoxState("MapTradingButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1
			
		if(inputClass.getFunctionName() == "TechTradingButton"):
			if(screen.getCheckBoxState("TechTradingButton")):
				screen.changeImageButton("TechTradingButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("TechTradingButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setTechTrading(screen.getCheckBoxState("TechTradingButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1
											
		if(inputClass.getFunctionName() == "GoldTradingButton"):
			if(screen.getCheckBoxState("GoldTradingButton")):
				screen.changeImageButton("GoldTradingButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("GoldTradingButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setGoldTrading(screen.getCheckBoxState("GoldTradingButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1

		if(inputClass.getFunctionName() == "OpenBordersTradingButton"):
			if(screen.getCheckBoxState("OpenBordersTradingButton")):
				screen.changeImageButton("OpenBordersTradingButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("OpenBordersTradingButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setOpenBordersTrading(screen.getCheckBoxState("OpenBordersTradingButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1
																
		if(inputClass.getFunctionName() == "DefensivePactTradingButton"):
			if(screen.getCheckBoxState("DefensivePactTradingButton")):
				screen.changeImageButton("DefensivePactTradingButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("DefensivePactTradingButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setDefensivePactTrading(screen.getCheckBoxState("DefensivePactTradingButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1

		if(inputClass.getFunctionName() == "PermanentAllianceTradingButton"):
			if(screen.getCheckBoxState("PermanentAllianceTradingButton")):
				screen.changeImageButton("PermanentAllianceTradingButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("PermanentAllianceTradingButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setPermanentAllianceTrading(screen.getCheckBoxState("PermanentAllianceTradingButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1

		if(inputClass.getFunctionName() == "VassalStateTradingButton"):
			if(screen.getCheckBoxState("VassalStateTradingButton")):
				screen.changeImageButton("VassalStateTradingButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("VassalStateTradingButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setVassalStateTrading(screen.getCheckBoxState("VassalStateTradingButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1

		if(inputClass.getFunctionName() == "BridgeBuildingButton"):
			if(screen.getCheckBoxState("BridgeBuildingButton")):
				screen.changeImageButton("BridgeBuildingButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("BridgeBuildingButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setBridgeBuilding(screen.getCheckBoxState("BridgeBuildingButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1


		if(inputClass.getFunctionName() == "InnerIrrigationButton"):
			if(screen.getCheckBoxState("InnerIrrigationButton")):
				screen.changeImageButton("InnerIrrigationButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("InnerIrrigationButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setIrrigation(screen.getCheckBoxState("InnerIrrigationButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1
			

		if(inputClass.getFunctionName() == "IgnoreIrrigationButton"):
			if(screen.getCheckBoxState("IgnoreIrrigationButton")):
				screen.changeImageButton("IgnoreIrrigationButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("IgnoreIrrigationButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setIgnoreIrrigation(screen.getCheckBoxState("IgnoreIrrigationButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1
			

		if(inputClass.getFunctionName() == "WaterWorkButton"):
			if(screen.getCheckBoxState("WaterWorkButton")):
				screen.changeImageButton("WaterWorkButton", "Art/Interface/Buttons/checked.dds")
			else:
				screen.changeImageButton("WaterWorkButton", "Art/Interface/Buttons/unchecked.dds")			

			gc.getTechInfo(self.iSelectedTech).setWaterWork(screen.getCheckBoxState("WaterWorkButton"))
			self.placeTechs(self.iSelectedTech)
			
			return 1


		if(inputClass.getFunctionName() == "Minimize"):
			self.bMinimized = true
			
			#self.updateTechRecords(false)
			screen.setButtonGFC( "Maximize", u"", "", (1024/2)+((1024/2)/2)+((1024/2)/2)-60, 55+(55/4)+12, 20, 20, WidgetTypes.WIDGET_GENERAL, -1, -1, ButtonStyles.BUTTON_STYLE_CITY_PLUS )

			screen.hide("InnerTechInfoDetailsPanel")
			screen.hide("TechInfoDetailsPanel")
			screen.hide("TechInfoClose")
			screen.setPanelSize( "TechInfoPanel", (1024/2)-18, 55, (1024/2), 90+12)
			

			return 1

		if(inputClass.getFunctionName() == "Maximize"):
			self.bMinimized = False
			#self.updateTechRecords(false)
			screen.setButtonGFC( "Minimize", u"", "", (1024/2)+((1024/2)/2)+((1024/2)/2)-60, 55+(55/4)+12, 20, 20, WidgetTypes.WIDGET_GENERAL, -1, -1, ButtonStyles.BUTTON_STYLE_CITY_MINUS )
	
			screen.show("InnerTechInfoDetailsPanel")
			screen.show("TechInfoDetailsPanel")
			screen.show("TechInfoClose")
	
			screen.setPanelSize( "TechInfoPanel", (1024/2)-18, 55, (1024/2), (713-75))
			
		if(inputClass.getFunctionName() == "UpperCenterLocationValue"):
			gc.getTechInfo(self.iSelectedTech).setGridY(gc.getTechInfo(self.iSelectedTech).getGridY()-1)
			self.placeTechs(self.iSelectedTech)
			self.drawArrows(self.iSelectedTech)
			
			szLocation = "(%s , %s)" %(gc.getTechInfo(self.iSelectedTech).getGridX(), gc.getTechInfo(self.iSelectedTech).getGridY())
			szUpArrow = "     &#47;&#92;"
			szDownArrow = "      &#92;&#47;"
			
			screen.attachTextGFC("UpperCenterLocationPanel", "UpperCenterLocationValue", szUpArrow.center(len(szLocation)-4), FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
			screen.attachLabel( "MiddleCenterLocationPanel", "MiddleCenterLocationValue", szLocation)
			screen.attachTextGFC("BottomCenterLocationPanel", "BottomCenterLocationValue", szDownArrow.center(len(szLocation)-4), FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

			return 1
	
		if(inputClass.getFunctionName() == "BottomCenterLocationValue"):
			gc.getTechInfo(self.iSelectedTech).setGridY(gc.getTechInfo(self.iSelectedTech).getGridY()+1)
			self.placeTechs(self.iSelectedTech)
			self.drawArrows(self.iSelectedTech)
			
			szLocation = "(%s , %s)" %(gc.getTechInfo(self.iSelectedTech).getGridX(), gc.getTechInfo(self.iSelectedTech).getGridY())
			szUpArrow = "     &#47;&#92;"
			szDownArrow = "      &#92;&#47;"
			
			screen.attachTextGFC("UpperCenterLocationPanel", "UpperCenterLocationValue", szUpArrow.center(len(szLocation)-4), FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
			screen.attachLabel( "MiddleCenterLocationPanel", "MiddleCenterLocationValue", szLocation)
			screen.attachTextGFC("BottomCenterLocationPanel", "BottomCenterLocationValue", szDownArrow.center(len(szLocation)-4), FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
			
			return 1
			
		if(inputClass.getFunctionName() == "MiddleLeftLocationValue"):
			gc.getTechInfo(self.iSelectedTech).setGridX(gc.getTechInfo(self.iSelectedTech).getGridX()-1)
			self.placeTechs(self.iSelectedTech)
			self.drawArrows(self.iSelectedTech)
			
			szLocation = "(%s , %s)" %(gc.getTechInfo(self.iSelectedTech).getGridX(), gc.getTechInfo(self.iSelectedTech).getGridY())
			szUpArrow = "     &#47;&#92;"
			szDownArrow = "      &#92;&#47;"
			
			screen.attachTextGFC("UpperCenterLocationPanel", "UpperCenterLocationValue", szUpArrow.center(len(szLocation)-4), FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
			screen.attachLabel( "MiddleCenterLocationPanel", "MiddleCenterLocationValue", szLocation)
			screen.attachTextGFC("BottomCenterLocationPanel", "BottomCenterLocationValue", szDownArrow.center(len(szLocation)-4), FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
			
			return 1

		if(inputClass.getFunctionName() == "MiddleRightLocationValue"):
			gc.getTechInfo(self.iSelectedTech).setGridX(gc.getTechInfo(self.iSelectedTech).getGridX()+1)
			self.placeTechs(self.iSelectedTech)
			self.drawArrows(self.iSelectedTech)
			
			szLocation = "(%s , %s)" %(gc.getTechInfo(self.iSelectedTech).getGridX(), gc.getTechInfo(self.iSelectedTech).getGridY())
			szUpArrow = "     &#47;&#92;"
			szDownArrow = "      &#92;&#47;"
			
			screen.attachTextGFC("UpperCenterLocationPanel", "UpperCenterLocationValue", szUpArrow.center(len(szLocation)-4), FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
			screen.attachLabel( "MiddleCenterLocationPanel", "MiddleCenterLocationValue", szLocation)
			screen.attachTextGFC("BottomCenterLocationPanel", "BottomCenterLocationValue", szDownArrow.center(len(szLocation)-4), FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
			
			return 1			

		if(inputClass.getFunctionName() == "AdvisorDDL" and self.iSelectedTech > -1):
	
			gc.getTechInfo(self.iSelectedTech).setAdvisorType(screen.getSelectedPullDownID("AdvisorDDL"))
			self.placeTechs(self.iSelectedTech)

			return 1

		if(inputClass.getFunctionName() == "EraDDL" and self.iSelectedTech > -1):
	
			gc.getTechInfo(self.iSelectedTech).setEra(screen.getSelectedPullDownID("EraDDL"))
			self.placeTechs(self.iSelectedTech)

			return 1

		if(inputClass.getFunctionName() == "FirstFreeUnitClassDDL" and self.iSelectedTech > -1):

			gc.getTechInfo(self.iSelectedTech).setFirstFreeUnitClass(screen.getSelectedPullDownID("FirstFreeUnitClassDDL")-1)
			self.placeTechs(self.iSelectedTech)
			

			return 1

		
		if(inputClass.getFunctionName() == "TechInfoClose" and self.iSelectedTech > -1):

			#screen.setText( "TopPanelDebugMsg", "TopPanel", "%s " %(screen.getSelectedPullDownID("FirstFreeUnitClassDDL"))
			#		, CvUtil.FONT_RIGHT_JUSTIFY, 1010, 20, -10, FontTypes.SMALL_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
	
			gc.getTechInfo(self.iSelectedTech).setAdvisorType(screen.getSelectedPullDownID("AdvisorDDL"))
			gc.getTechInfo(self.iSelectedTech).setEra(screen.getSelectedPullDownID("EraDDL"))
			gc.getTechInfo(self.iSelectedTech).setFirstFreeUnitClass(screen.getSelectedPullDownID("FirstFreeUnitClassDDL")-1)
			
			screen.setPanelColor("TechRecord" + str(self.iSelectedTech), 100, 104, 160)
			screen.hide("TechInfoDetailsPanel")	
			screen.hide("TechInfoPanel")
			screen.hide("TechNamePanel")
			screen.hide("TechInfoName")
			screen.hide("techButton")
			screen.hide("DeleteTechButton")
			screen.hide("InnerTechInfoDetailsPanel")
			screen.hide("TechInfoClose")
			screen.hide("Maximize")
			screen.hide("Minimize")

			self.iOldSelectedTech = -1
			self.iSelectedTech = -1

			return 1

			
		if(inputClass.getFunctionName() == "AIWeightSlider" and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getAIWeight()):

			gc.getTechInfo(self.iSelectedTech).setAIWeight(inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", "AIWeightValue", "<font=3>%s</font>" %(str(gc.getTechInfo(self.iSelectedTech).getAIWeight())))
			screen.attachControlToTableCell("AIWeightValue","TechEditTable", 1,2)
		
			return 1
			
		if(inputClass.getFunctionName() == "AITradeModifierSlider" and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getAITradeModifier()):

			gc.getTechInfo(self.iSelectedTech).setAITradeModifier(inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", "AITradeModifierValue", "<font=3>%s</font>" %(str(gc.getTechInfo(self.iSelectedTech).getAITradeModifier())))
			screen.attachControlToTableCell("AITradeModifierValue","TechEditTable", 2,2)
		
			return 1

		
		if(inputClass.getFunctionName() == "ResearchCostSlider" and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getResearchCost()):

			gc.getTechInfo(self.iSelectedTech).setResearchCost(inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", "ResearchCostValue", "<font=3>%s</font>" %(str(gc.getTechInfo(self.iSelectedTech).getResearchCost())))
			screen.attachControlToTableCell("ResearchCostValue","TechEditTable", 3,2)
		
			return 1

		if(inputClass.getFunctionName() == "FeatureProductionModifierSlider" and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getFeatureProductionModifier()):

			gc.getTechInfo(self.iSelectedTech).setFeatureProductionModifier(inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", "FeatureProductionModifierValue", "<font=3>%s</font>" %(str(gc.getTechInfo(self.iSelectedTech).getFeatureProductionModifier())))
			screen.attachControlToTableCell("FeatureProductionModifierValue","TechEditTable", 5,2)
			self.placeTechs(self.iSelectedTech)
		
			return 1
			
			
		if(inputClass.getFunctionName() == "TradeRoutesSlider" and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getTradeRoutes()):

			gc.getTechInfo(self.iSelectedTech).setTradeRoutes(inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", "TradeRoutesValue", "<font=3>%s</font>" %(str(gc.getTechInfo(self.iSelectedTech).getTradeRoutes())))
			screen.attachControlToTableCell("TradeRoutesValue","TechEditTable", 6,2)
			self.placeTechs(self.iSelectedTech)
		
			return 1

			
		if(inputClass.getFunctionName() == "WorkerSpeedModifierSlider" and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getWorkerSpeedModifier()):

			gc.getTechInfo(self.iSelectedTech).setWorkerSpeedModifier(inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", "WorkerSpeedModifierValue", "<font=3>%s</font>" %(str(gc.getTechInfo(self.iSelectedTech).getWorkerSpeedModifier())))
			screen.attachControlToTableCell("WorkerSpeedModifierValue","TechEditTable", 7,2)
			self.placeTechs(self.iSelectedTech)
		
			return 1


		if(inputClass.getFunctionName() == "HealthSlider" and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getHealth()):

			gc.getTechInfo(self.iSelectedTech).setHealth(inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", "HealthValue", "<font=3>%s</font>" %(str(gc.getTechInfo(self.iSelectedTech).getHealth())))
			screen.attachControlToTableCell("HealthValue","TechEditTable", 9,2)
		
			self.placeTechs(self.iSelectedTech)

			return 1


		if(inputClass.getFunctionName() == "HappinessSlider" and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getHappiness()):

			gc.getTechInfo(self.iSelectedTech).setHappiness(inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", "HappinessValue", "<font=3>%s</font>" %(str(gc.getTechInfo(self.iSelectedTech).getHappiness())))
			screen.attachControlToTableCell("HappinessValue","TechEditTable", 10,2)
		
			self.placeTechs(self.iSelectedTech)

			return 1

		if(inputClass.getFunctionName() == "FirstFreeTechsSlider" and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getFirstFreeTechs()):

			gc.getTechInfo(self.iSelectedTech).setFirstFreeTechs(inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", "FirstFreeTechsValue", "<font=3>%s</font>" %(str(gc.getTechInfo(self.iSelectedTech).getFirstFreeTechs())))
			screen.attachControlToTableCell("FirstFreeTechsValue","TechEditTable", 11,2)
			self.placeTechs(self.iSelectedTech)

			return 1
			
		if(inputClass.getFunctionName() == "AssetSlider" and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getAssetValue()):

			gc.getTechInfo(self.iSelectedTech).setAssetValue(inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", "AssetValue", "<font=3>%s</font>" %(str(gc.getTechInfo(self.iSelectedTech).getAssetValue())))
			screen.attachControlToTableCell("AssetValue","TechEditTable", 12,2)

			return 1

		if(inputClass.getFunctionName() == "PowerSlider" and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getPowerValue()):

			gc.getTechInfo(self.iSelectedTech).setPowerValue(inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", "PowerValue", "<font=3>%s</font>" %(str(gc.getTechInfo(self.iSelectedTech).getPowerValue())))
			screen.attachControlToTableCell("PowerValue","TechEditTable", 13,2)
			return 1

		if(inputClass.getFunctionName().endswith("UnitsExtraMovesSlider") and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getDomainExtraMoves(inputClass.getData1())):
			gc.getTechInfo(self.iSelectedTech).setDomainExtraMoves(inputClass.getData1(), inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", str("%sExtraMovesValue" %(gc.getDomainInfo(inputClass.getData1()).getDescription().replace(" ",""))), "<font=3>%s</font>" %(gc.getTechInfo(self.iSelectedTech).getDomainExtraMoves(inputClass.getData1())))
			screen.attachControlToTableCell(str("%sExtraMovesValue" %(gc.getDomainInfo(inputClass.getData1()).getDescription().replace(" ",""))),"DomainExtraMovesTable", inputClass.getData1(),3)

			self.placeTechs(self.iSelectedTech)

			return 1

		if(inputClass.getFunctionName().endswith("ValuesSlider") and self.iSelectedTech > -1 and inputClass.getNotifyCode() == NotifyCode.NOTIFY_SLIDER_NEWSTOP and inputClass.getData() != gc.getTechInfo(self.iSelectedTech).getFlavorValue(inputClass.getData1())):
			gc.getTechInfo(self.iSelectedTech).setFlavorValue(inputClass.getData1(), inputClass.getData())
			screen.attachLabel( "InnerTechInfoDetailsPanel", str("%sValuesValue" %(gc.getFlavorTypes(inputClass.getData1()).replace(" ",""))), "<font=3>%s</font>" %(gc.getTechInfo(self.iSelectedTech).getFlavorValue(inputClass.getData1())))
			screen.attachControlToTableCell(str("%sValuesValue" %(gc.getFlavorTypes(inputClass.getData1()).replace(" ",""))),"FlavorValuesTable", inputClass.getData1(),3)

			self.placeTechs(self.iSelectedTech)

			return 1

		if(inputClass.getButtonType() == WidgetTypes.WIDGET_EDIT_TECH and inputClass.getData1() >= 0):
			
			if(self.iSelectedTech != inputClass.getData1()):
				self.iOldSelectedTech = self.iSelectedTech
			self.iSelectedTech = inputClass.getData1()

			self.updateTechRecords(false)
			return 1

		return 0

	def getNextWidgetName(self):
		szName = "TechArrow" + str(self.nWidgetCount)
		self.nWidgetCount += 1
		
		return szName

	def getXStart(self):
		return ( BOX_INCREMENT_WIDTH * PIXEL_INCREMENT )
		
	def getXSpacing(self):
		return ( BOX_INCREMENT_X_SPACING * PIXEL_INCREMENT )
										
	def getYStart(self, iY):
		return int((((BOX_INCREMENT_HEIGHT * PIXEL_INCREMENT ) / 6.0) * iY) - PIXEL_INCREMENT )

	def getWidth(self, xDiff):
		return ( ( xDiff * self.getXSpacing() ) + ( ( xDiff - 1 ) * self.getXStart() ) )
		
	def getHeight(self, yDiff, nFactor):
		return ( ( nFactor + ( ( abs( yDiff ) - 1 ) * 6 ) ) * PIXEL_INCREMENT )
		
	def update(self, fDelta):
		return

